Testing support for the LightDI framework
Designed to make writing integration test easier for LightDI.
-
Creating and injecting mock beans into the application context using @MockBean and @SpyBean
-
Creating property overrides using @TestPropertySource
-
Supporting @Autowire to the JUnit test class
Include the jar file in your project. You can do this using Maven:
<dependency>
<groupId>com.helospark</groupId>
<artifactId>lightdi-test</artifactId>
<version>${lightdi-test.version}</version>
</dependency>
(Check mvnrepository.com for the latest version).
You can also download the single-jar version from Maven central for direct usage:
(jar-with-dependencies is a Maven classifier, if you would like to use the fat jar using Maven)
Annotate beans with above annotations
@RunWith(LightDiJUnitTestRunner.class)
@LightDiTest(rootPackage = "com.helospark.context") // You can also use class
public class JUnitRunnerTest {
@Autowired
private TestDependency testDependency;
@MockBean
private BeanToOverride beanToOverride;
@Test
public void test() {
//...
}
}