use of org.junit.runner.Description in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method step_descriptions_can_be_turned_on.
@Test
void step_descriptions_can_be_turned_on() {
Feature cucumberFeature = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: feature name\n" + " Background:\n" + " Given background step\n" + " Scenario: A\n" + " Then scenario name\n" + " Scenario: B\n" + " Then scenario name\n" + " Scenario Outline: C\n" + " Then scenario <name>\n" + " Examples:\n" + " | name |\n" + " | C |\n" + " | D |\n" + " | E |\n");
JUnitOptions junitOption = new JUnitOptionsBuilder().setStepNotifications(true).build();
FeatureRunner runner = createFeatureRunner(cucumberFeature, junitOption);
Description feature = runner.getDescription();
Description scenarioA = feature.getChildren().get(0);
assertThat(scenarioA.getChildren().size(), is(equalTo(2)));
Description scenarioB = feature.getChildren().get(1);
assertThat(scenarioB.getChildren().size(), is(equalTo(2)));
Description scenarioC0 = feature.getChildren().get(2);
assertThat(scenarioC0.getChildren().size(), is(equalTo(2)));
Description scenarioC1 = feature.getChildren().get(3);
assertThat(scenarioC1.getChildren().size(), is(equalTo(2)));
Description scenarioC2 = feature.getChildren().get(4);
assertThat(scenarioC2.getChildren().size(), is(equalTo(2)));
}
use of org.junit.runner.Description in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method should_populate_descriptions_with_stable_unique_ids.
@Test
void should_populate_descriptions_with_stable_unique_ids() {
Feature feature = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: feature name\n" + " Background:\n" + " Given background step\n" + " Scenario: A\n" + " Then scenario name\n" + " Scenario: B\n" + " Then scenario name\n" + " Scenario Outline: C\n" + " Then scenario <name>\n" + " Examples:\n" + " | name |\n" + " | C |\n" + " | D |\n" + " | E |\n");
FeatureRunner runner = createFeatureRunner(feature, new JUnitOptions());
FeatureRunner rerunner = createFeatureRunner(feature, new JUnitOptions());
Set<Description> descriptions = new HashSet<>();
assertDescriptionIsUnique(runner.getDescription(), descriptions);
assertDescriptionIsPredictable(runner.getDescription(), descriptions);
assertDescriptionIsPredictable(rerunner.getDescription(), descriptions);
}
use of org.junit.runner.Description in project cucumber-jvm by cucumber.
the class FeatureRunnerTest method should_notify_of_failure_to_create_runners_and_request_test_execution_to_stop.
@Test
void should_notify_of_failure_to_create_runners_and_request_test_execution_to_stop() {
Feature feature = TestPickleBuilder.parseFeature("path/test.feature", "" + "Feature: feature name\n" + " Scenario: scenario_1 name\n" + " Given step #1\n");
Filters filters = new Filters(RuntimeOptions.defaultOptions());
IllegalStateException illegalStateException = new IllegalStateException();
RunnerSupplier runnerSupplier = () -> {
throw illegalStateException;
};
TimeServiceEventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
RuntimeOptions options = RuntimeOptions.defaultOptions();
CucumberExecutionContext context = new CucumberExecutionContext(bus, new ExitStatus(options), runnerSupplier);
FeatureRunner featureRunner = FeatureRunner.create(feature, null, filters, context, new JUnitOptions());
RunNotifier notifier = mock(RunNotifier.class);
PickleRunners.PickleRunner pickleRunner = featureRunner.getChildren().get(0);
featureRunner.runChild(pickleRunner, notifier);
Description description = pickleRunner.getDescription();
ArgumentCaptor<Failure> failureArgumentCaptor = ArgumentCaptor.forClass(Failure.class);
InOrder order = inOrder(notifier);
order.verify(notifier).fireTestStarted(description);
order.verify(notifier).fireTestFailure(failureArgumentCaptor.capture());
assertThat(failureArgumentCaptor.getValue().getException(), is(equalTo(illegalStateException)));
assertThat(failureArgumentCaptor.getValue().getDescription(), is(equalTo(description)));
order.verify(notifier).pleaseStop();
order.verify(notifier).fireTestFinished(description);
}
use of org.junit.runner.Description in project mockito by mockito.
the class UnnecessaryStubbingsReporter method validateUnusedStubs.
public void validateUnusedStubs(Class<?> testClass, RunNotifier notifier) {
Collection<Invocation> unused = new UnusedStubbingsFinder().getUnusedStubbingsByLocation(mocks);
if (unused.isEmpty()) {
// whoa!!! All stubbings were used!
return;
}
// Oups, there are unused stubbings
Description unnecessaryStubbings = Description.createTestDescription(testClass, "unnecessary Mockito stubbings");
notifier.fireTestFailure(new Failure(unnecessaryStubbings, Reporter.formatUnncessaryStubbingException(testClass, unused)));
}
use of org.junit.runner.Description in project restfuse by eclipsesource.
the class RequestConfiguration_Test method testPathWithNonExistingSegments.
@Test(expected = IllegalStateException.class)
public void testPathWithNonExistingSegments() {
Description method = mock(Description.class);
HttpTest annotation = createAnnotation("/people/{invalid}/name");
when(method.getAnnotation(HttpTest.class)).thenReturn(annotation);
RequestConfiguration config = new RequestConfiguration("http://www.fake.com", method, new Object());
RequestContext context = new RequestContext();
context.addPathSegment("id", "12345");
config.createRequest(context);
}
Aggregations