Skip to content
Pierre T. edited this page Jan 9, 2015 · 4 revisions

Dependency

To use the testing features provided by Nuun add the following dependency to your pom.

<dependency>
    <groupId>io.nuun</groupId>
    <artifactId>kernel-tests</artifactId>
    <version>${nuunkernel.version}</version>
    <scope>test</scope>
</dependency>

Usage

JUnit runner

Integration tests in Nuun are done using the NuunITRunner. This runner starts a Nuun kernel and bind the test class so you can inject bound class in it.

Nuun IT also provides a @WithParams annotation which allows to pass params to the kernel.

@WithParams({Kernel.NUUN_ROOT_PACKAGE, "org.mycompany.myproject"})
@RunWith(NuunITRunner.class)
public class ServiceAIT {
    
    @Inject
    ServiceA serviceA;
    
    @Test
    public void ServiceAShouldDoSomethingUseful() {
        Assertions.assertThat(serviceA).isNotNull();
        serviceA.doSomethingUseful();
        ...
    }
}

Bindings

The test class is automatically bind by you may want to bind other classes for your testing needs. Nuun provides two API for that:

  • The @ITBind annotation which can be used on a class to bind it
  • The @KernelModule annotation which is used to bind native module without having to create a plugin. This feature is only available for test purpose.

Content

Clone this wiki locally