Search in sources :

Example 1 with Glue

use of cucumber.runtime.Glue in project cucumber-jvm by cucumber.

the class MethodScannerTest method loadGlue_registers_the_methods_declaring_class_in_the_object_factory.

@Test
public void loadGlue_registers_the_methods_declaring_class_in_the_object_factory() throws NoSuchMethodException {
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    ResourceLoader resourceLoader = new MultiLoader(classLoader);
    MethodScanner methodScanner = new MethodScanner(new ResourceLoaderClassFinder(resourceLoader, classLoader));
    ObjectFactory factory = Mockito.mock(ObjectFactory.class);
    Glue world = Mockito.mock(Glue.class);
    JavaBackend backend = new JavaBackend(factory);
    Whitebox.setInternalState(backend, "glue", world);
    // this delegates to methodScanner.scan which we test
    methodScanner.scan(backend, BaseStepDefs.class.getMethod("m"), BaseStepDefs.class);
    verify(factory, times(1)).addClass(BaseStepDefs.class);
    verifyNoMoreInteractions(factory);
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) ResourceLoaderClassFinder(cucumber.runtime.io.ResourceLoaderClassFinder) ObjectFactory(cucumber.api.java.ObjectFactory) Glue(cucumber.runtime.Glue) MultiLoader(cucumber.runtime.io.MultiLoader) Test(org.junit.Test)

Aggregations

ObjectFactory (cucumber.api.java.ObjectFactory)1 Glue (cucumber.runtime.Glue)1 MultiLoader (cucumber.runtime.io.MultiLoader)1 ResourceLoader (cucumber.runtime.io.ResourceLoader)1 ResourceLoaderClassFinder (cucumber.runtime.io.ResourceLoaderClassFinder)1 Test (org.junit.Test)1