use of io.cucumber.core.backend.Options in project cucumber-jvm by cucumber.
the class ObjectFactoryServiceLoaderTest method shouldThrowIfDefaultObjectFactoryServiceCouldNotBeLoaded.
@Test
void shouldThrowIfDefaultObjectFactoryServiceCouldNotBeLoaded() {
Options options = () -> null;
Supplier<ClassLoader> classLoader = () -> new FilteredClassLoader("META-INF/services/io.cucumber.core.backend.ObjectFactory");
ObjectFactoryServiceLoader loader = new ObjectFactoryServiceLoader(classLoader, options);
CucumberException exception = assertThrows(CucumberException.class, loader::loadObjectFactory);
assertThat(exception.getMessage(), is("" + "Could not find any object factory.\n" + "\n" + "Cucumber uses SPI to discover object factory implementations.\n" + "This typically happens when using shaded jars. Make sure\n" + "to merge all SPI definitions in META-INF/services correctly"));
}
use of io.cucumber.core.backend.Options in project cucumber-jvm by cucumber.
the class ObjectFactoryServiceLoaderTest method shouldThrowIfSelectedObjectFactoryServiceCouldNotBeLoaded.
@Test
void shouldThrowIfSelectedObjectFactoryServiceCouldNotBeLoaded() {
Options options = () -> NoSuchObjectFactory.class;
Supplier<ClassLoader> classLoader = () -> new FilteredClassLoader("META-INF/services/io.cucumber.core.backend.ObjectFactory");
ObjectFactoryServiceLoader loader = new ObjectFactoryServiceLoader(classLoader, options);
CucumberException exception = assertThrows(CucumberException.class, loader::loadObjectFactory);
assertThat(exception.getMessage(), is("" + "Could not find object factory io.cucumber.core.runtime.ObjectFactoryServiceLoaderTest$NoSuchObjectFactory.\n" + "\n" + "Cucumber uses SPI to discover object factory implementations.\n" + "Has the class been registered with SPI and is it available on\n" + "the classpath?"));
}
use of io.cucumber.core.backend.Options in project cucumber-jvm by cucumber.
the class ObjectFactoryServiceLoaderTest method shouldLoadDefaultObjectFactoryService.
@Test
void shouldLoadDefaultObjectFactoryService() {
Options options = () -> null;
ObjectFactoryServiceLoader loader = new ObjectFactoryServiceLoader(ObjectFactoryServiceLoaderTest.class::getClassLoader, options);
assertThat(loader.loadObjectFactory(), instanceOf(DefaultObjectFactory.class));
}
use of io.cucumber.core.backend.Options in project cucumber-jvm by cucumber.
the class ObjectFactoryServiceLoaderTest method shouldLoadSelectedObjectFactoryService.
@Test
void shouldLoadSelectedObjectFactoryService() {
Options options = () -> DefaultObjectFactory.class;
ObjectFactoryServiceLoader loader = new ObjectFactoryServiceLoader(ObjectFactoryServiceLoaderTest.class::getClassLoader, options);
assertThat(loader.loadObjectFactory(), instanceOf(DefaultObjectFactory.class));
}
Aggregations