Test project

Report a typo

Your project contains the following components.

Main Application class:

Java
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

DependentComponent class:

@Component
public class DependentComponent{
    
    // some logic
}

MainComponent class:

@Component
public class MainComponent{

    @Autowired
    private DependentComponent dependentComponent;

    // some logic

}

It's time to write a test for MainComponent!

// 1
class MainComponentTest {

    // 2
    private MainComponent component;

    // 3
    void testComponent(){
        // assertThat...
    }
}
Kotlin

Main Application class:

@SpringBootApplication
class Application

fun main(args: Array<String>) {
    runApplication<Application>(*args)
}

DependentComponent class:

@Component
class DependentComponent {

    // some logic
}

MainComponent class:

@Component
class MainComponent {
    
    @Autowired
    private lateinit var dependentComponent: DependentComponent
    
    // some logic
}

It's time to write a test for MainComponent!

// 1
class MainComponentTest {
    // 2
    private lateinit var component: MainComponent

    // 3
    fun testComponent() {
        // assertThat...
    }
}

Match all commented lines with the corresponding annotation.

Match the items from left and right columns
// 1
// 2
// 3
extra annotation
@ExtendWith(SpringExtension.class) (@ExtendWith(SpringExtension::class in Kotlin))
@SpringBootTest
@Test
@Autowired
___

Create a free account to access the full topic