use of org.junit.jupiter.api.function.Executable in project cucumber-jvm by cucumber.
the class FeatureIdentifierTest method reject_directory_form.
@Test
void reject_directory_form() {
Executable testMethod = () -> FeatureIdentifier.parse(URI.create("classpath:/path/to"));
IllegalArgumentException actualThrown = assertThrows(IllegalArgumentException.class, testMethod);
assertThat("Unexpected exception message", actualThrown.getMessage(), is(equalTo("featureIdentifier does not reference a single feature file: classpath:/path/to")));
}
use of org.junit.jupiter.api.function.Executable in project cucumber-jvm by cucumber.
the class SpringFactoryTest method shouldFailIfClassWithSpringComponentAnnotationsIsFound.
@Test
void shouldFailIfClassWithSpringComponentAnnotationsIsFound() {
final ObjectFactory factory = new SpringFactory();
Executable testMethod = () -> factory.addClass(WithComponentAnnotation.class);
CucumberBackendException actualThrown = assertThrows(CucumberBackendException.class, testMethod);
assertThat(actualThrown.getMessage(), is(equalTo("Glue class io.cucumber.spring.componentannotation.WithComponentAnnotation was annotated with @Component; marking it as a candidate for auto-detection by Spring. Glue classes are detected and registered by Cucumber. Auto-detection of glue classes by spring may lead to duplicate bean definitions. Please remove the @Component annotation")));
}
use of org.junit.jupiter.api.function.Executable in project cucumber-jvm by cucumber.
the class SpringFactoryTest method shouldFailIfMultipleClassesWithSpringAnnotationsAreFound.
@Test
void shouldFailIfMultipleClassesWithSpringAnnotationsAreFound() {
final ObjectFactory factory = new SpringFactory();
factory.addClass(WithSpringAnnotations.class);
Executable testMethod = () -> factory.addClass(BellyStepDefinitions.class);
CucumberBackendException actualThrown = assertThrows(CucumberBackendException.class, testMethod);
assertThat(actualThrown.getMessage(), startsWith("Glue class class io.cucumber.spring.contextconfig.BellyStepDefinitions and class io.cucumber.spring.SpringFactoryTest$WithSpringAnnotations are both annotated with @CucumberContextConfiguration.\n" + "Please ensure only one class configures the spring context"));
}
use of org.junit.jupiter.api.function.Executable in project cucumber-jvm by cucumber.
the class AssertionsTest method should_throw_cucumber_exception_when_annotated.
@Test
void should_throw_cucumber_exception_when_annotated() {
Executable testMethod = () -> Assertions.assertNoCucumberAnnotatedMethods(WithCucumberMethod.class);
CucumberException expectedThrown = assertThrows(CucumberException.class, testMethod);
assertThat(expectedThrown.getMessage(), is(equalTo("\n\n" + "Classes annotated with @RunWith(Cucumber.class) must not define any\n" + "Step Definition or Hook methods. Their sole purpose is to serve as\n" + "an entry point for JUnit. Step Definitions and Hooks should be defined\n" + "in their own classes. This allows them to be reused across features.\n" + "Offending class: class io.cucumber.junit.AssertionsTest$WithCucumberMethod\n")));
}
use of org.junit.jupiter.api.function.Executable in project cucumber-jvm by cucumber.
the class CucumberTest method no_stepdefs_in_cucumber_runner_invalid.
@Test
void no_stepdefs_in_cucumber_runner_invalid() {
Executable testMethod = () -> Assertions.assertNoCucumberAnnotatedMethods(Invalid.class);
CucumberException expectedThrown = assertThrows(CucumberException.class, testMethod);
assertThat(expectedThrown.getMessage(), is(equalTo("\n\nClasses annotated with @RunWith(Cucumber.class) must not define any\nStep Definition or Hook methods. Their sole purpose is to serve as\nan entry point for JUnit. Step Definitions and Hooks should be defined\nin their own classes. This allows them to be reused across features.\nOffending class: class io.cucumber.junit.CucumberTest$Invalid\n")));
}
Aggregations