Guice JUnit Runner

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

License

License

Categories

Categories

JUnit Unit Testing Net GUI User Interface Guice Application Layer Libs Dependency Injection
GroupId

GroupId

net.lamberto.junit
ArtifactId

ArtifactId

guice-junit-runner
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

Guice JUnit Runner
A JUnit Runner allowing Guice-based testing. Each test method is running with a clean Injector instance.
Project URL

Project URL

https://github.com/marcolamberto/guice-junit-runner
Source Code Management

Source Code Management

https://github.com/marcolamberto/guice-junit-runner.git

Download guice-junit-runner

How to add to project

<!-- https://jarcasting.com/artifacts/net.lamberto.junit/guice-junit-runner/ -->
<dependency>
    <groupId>net.lamberto.junit</groupId>
    <artifactId>guice-junit-runner</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/net.lamberto.junit/guice-junit-runner/
implementation 'net.lamberto.junit:guice-junit-runner:1.0.2'
// https://jarcasting.com/artifacts/net.lamberto.junit/guice-junit-runner/
implementation ("net.lamberto.junit:guice-junit-runner:1.0.2")
'net.lamberto.junit:guice-junit-runner:jar:1.0.2'
<dependency org="net.lamberto.junit" name="guice-junit-runner" rev="1.0.2">
  <artifact name="guice-junit-runner" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.lamberto.junit', module='guice-junit-runner', version='1.0.2')
)
libraryDependencies += "net.lamberto.junit" % "guice-junit-runner" % "1.0.2"
[net.lamberto.junit/guice-junit-runner "1.0.2"]

Dependencies

compile (4)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.16.18
com.google.guava : guava jar 23.0
com.google.inject : guice jar 4.1.0
junit : junit jar 4.12

test (5)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.12
ch.qos.logback : logback-classic jar 1.1.3
ch.qos.logback : logback-core jar 1.1.3
org.hamcrest : hamcrest-core jar 1.3
org.hamcrest : hamcrest-library jar 1.3

Project Modules

There are no modules declared in this project.

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

Versions

Version
1.0.2
1.0.1
1.0.0