Skip to content

bijukunjummen/governator-junit-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

governator-junit-runner

Build Status

Overview

This project aims to simplify integrating Netflix Governator in JUnit Tests.

This is how a Governator Junit test would look using this module:

@RunWith(GovernatorJunit4Runner.class)
@LifecycleInjectorParams(modules = SampleModule.class, scannedPackages = "governator.junit.demo")
public class SampleGovernatorRunnerTest {

    @Inject
    private BlogService blogService;

    @Test
    public void testExampleBeanInjection() throws Exception {
        assertNotNull(blogService.get(1l));
    }

}

This is in contrast to the more verbose code that results from using the JUnit @Rule provided by governator’s test support:

public class SampleGovernatorJunitSupportTest {

    @Rule
    public LifecycleTester tester = new LifecycleTester();

    @Test
    public void testExampleBeanInjection() throws Exception {
        tester.start();
        Injector injector = tester
                .builder()
                .usingBasePackages("sample.gov")
                .build()
                .createInjector();

        BlogService blogService = injector.getInstance(BlogService.class);
        assertThat(blogService.get(1l), is(notNullValue()));
    }

}

More Samples are in the test folder

Usage

Add the following dependency to your pom.xml file:

    <dependency>
      <groupId>com.github.bijukunjummen</groupId>
      <artifactId>governator-junit-runner</artifactId>
      <version>0.2.RELEASE</version>
      <scope>test</scope>
    </dependency>

About

Junit Runner support for Governator based modules

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages