@Test public void shouldCaptureOutcomeFailures() { FailingSteps steps = new FailingSteps(); List<StepCandidate> candidates = steps.listCandidates(); assertThat(candidates.size(), equalTo(1)); StepResult stepResult = candidates .get(0) .createMatchedStep("When outcome fails for Bar upon verification", namedParameters) .perform(null); assertThat(stepResult.getFailure(), instanceOf(UUIDExceptionWrapper.class)); assertThat(stepResult.getFailure().getCause(), instanceOf(OutcomesFailed.class)); }
@Test public void shouldCreatePerformableStepWithResultThatDescribesTheStepPerformed() throws Exception { StoryReporter reporter = mock(StoryReporter.class); SomeSteps someSteps = new SomeSteps(); Method method = SomeSteps.class.getMethod("aMethodWith", String.class); StepCandidate candidate = candidateWith("I live on the $nth floor", THEN, method, someSteps); StepResult result = candidate.createMatchedStep("Then I live on the 1st floor", namedParameters).perform(null); result.describeTo(reporter); verify(reporter) .successful( "Then I live on the " + PARAMETER_VALUE_START + "1st" + PARAMETER_VALUE_END + " floor"); }
@Test public void shouldCreateStepFromTableValuesWhenHeadersDoNotMatchParameterNames() throws Exception { AnnotationNamedParameterSteps steps = new AnnotationNamedParameterSteps(); // I speak LolCatz and mispell headerz namedParameters.put("itz", "first"); namedParameters.put("ntz", "ground"); String patternAsString = "I live on the ith floor but some call it the nth"; Method method = stepMethodFor( "methodWithNamedParametersInNaturalOrder", AnnotationNamedParameterSteps.class); StepCandidate candidate = candidateWith(patternAsString, WHEN, method, steps); String stepAsString = "When I live on the <ith> floor but some call it the <nth>"; Step step = candidate.createMatchedStep(stepAsString, namedParameters); StepResult perform = step.perform(null); assertThat(perform, instanceOf(AbstractStepResult.Pending.class)); assertThat(perform.parametrisedStep(), equalTo(stepAsString)); StepResult doNotPerform = step.doNotPerform(null); assertThat(doNotPerform, instanceOf(NotPerformed.class)); assertThat(doNotPerform.parametrisedStep(), equalTo(stepAsString)); }