Guice Edit on GitHub

Cuppa is agnostic about which inversion of control container you happen to be using. As such, Cuppa provides a hook to allow you to customise how your test classes are instantiated. To use Guice, you need to write a class that implements ConfigurationProvider and sets the class instantiator:

package com.example;

import com.google.inject.Guice;
import org.forgerock.cuppa.ConfigurationProvider;

public final class MyConfigurationProvider implements ConfigurationProvider {
    @Override
    public void configure(Configuration configuration) {
        // Setup Guice as needed...
        Injector injector = Guice.createInjector(new MyModule());
        configuration.setClassInstantiator(injector::getInstance);
    }
}

Cuppa uses a ServiceLoader to find the configuration provider. Hence, you need to provide a configuration file called META-INF/services/org.forgerock.cuppa.ConfigurationProvider that contains the fully-qualified class name of your class:

com.example.MyConfigurationProvider

Ensure that this file is on the classpath when running Cuppa.