Skip to content

richard-strate/guice-junit-runner

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

guice-junit-runner

Continuous Integration: Build Status

A Guice JUnit Runner

What is guice-junit-runner?

guice-junit-runner is a JUnit Runner allowing Guice-based testing. Each test method is running with a clean Injector instance.

Basic usage

@RunWith(GuiceJUnitRunner.class)
public class GuiceJUnitRunnerTest {
	@Inject
	public MyService service;

	@Test
	public void test() {
		// ...
	}
}

Using custom Guice modules

You can easily add one more modules by using the @GuiceModules annotation.

@RunWith(GuiceJUnitRunner.class)
@GuiceModules(TestModule.class)
public class GuiceJUnitRunnerTest {

	public static class TestModule extends AbstractModule {
		@Override
		protected void configure() {
			bind(MyService.class).to(MyServiceImpl.class);
			// ...
		}
	}


	@Inject
	public MyService service;

	@Test
	@GuiceModules(TestModule2.class)
	public void perTestSpecificModule() {
		// ...
	}

	@Test
	public void test() {
		// ...
	}
}

About

Guice JUnit Runner

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%