Skip to content

Latest commit

 

History

History
65 lines (45 loc) · 2.03 KB

README.adoc

File metadata and controls

65 lines (45 loc) · 2.03 KB

Build Status Coverage MIT licence PRs Welcome

LightDI Test

Testing support for the LightDI framework

Designed to make writing integration test easier for LightDI.

Features

  • 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

Usage

Include library

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)

Library usage

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() {
	      //...
	    }
	 }

Building and contribution

You can build using Maven:

     mvn clean install -DskipGpgSign

Feel free to open issues / pull requests.