Search in sources :

Example 6 with StepFinder

use of org.jbehave.core.steps.StepFinder in project jbehave-core by jbehave.

the class EmbedderBehaviour method shouldReportAllStepdocs.

@Test
public void shouldReportAllStepdocs() {
    // Given
    Embedder embedder = new Embedder();
    embedder.useCandidateSteps(asList((CandidateSteps) new MySteps()));
    embedder.configuration().useStepFinder(new StepFinder());
    OutputStream out = new ByteArrayOutputStream();
    embedder.configuration().useStepdocReporter(new PrintStreamStepdocReporter(new PrintStream(out)));
    // When
    embedder.reportStepdocs();
    // Then
    String output = dos2unix(out.toString());
    assertThat(output, containsString("'Given a given'\n" + "org.jbehave.core.embedder.EmbedderBehaviour$MySteps.given()\n"));
    assertThat(output, containsString("'When a when'\n" + "org.jbehave.core.embedder.EmbedderBehaviour$MySteps.when()\n"));
    assertThat(output, containsString("'Then a then'\n" + "org.jbehave.core.embedder.EmbedderBehaviour$MySteps.then()\n"));
    assertThat(output, containsString("from steps instances:\norg.jbehave.core.embedder.EmbedderBehaviour$MySteps\n"));
}
Also used : PrintStream(java.io.PrintStream) StepFinder(org.jbehave.core.steps.StepFinder) PrintStreamStepdocReporter(org.jbehave.core.reporters.PrintStreamStepdocReporter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) UsingEmbedder(org.jbehave.core.annotations.UsingEmbedder) CandidateSteps(org.jbehave.core.steps.CandidateSteps) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 7 with StepFinder

use of org.jbehave.core.steps.StepFinder in project jbehave-core by jbehave.

the class Embedder method reportMatchingStepdocs.

public void reportMatchingStepdocs(String stepAsString) {
    Configuration configuration = configuration();
    List<CandidateSteps> candidateSteps = candidateSteps();
    StepFinder finder = configuration.stepFinder();
    StepdocReporter reporter = configuration.stepdocReporter();
    List<Stepdoc> matching = finder.findMatching(stepAsString, candidateSteps);
    List<Object> stepsInstances = finder.stepsInstances(candidateSteps);
    reporter.stepdocsMatching(stepAsString, matching, stepsInstances);
}
Also used : StepFinder(org.jbehave.core.steps.StepFinder) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Stepdoc(org.jbehave.core.steps.Stepdoc) CandidateSteps(org.jbehave.core.steps.CandidateSteps) StepdocReporter(org.jbehave.core.reporters.StepdocReporter)

Example 8 with StepFinder

use of org.jbehave.core.steps.StepFinder in project jbehave-core by jbehave.

the class Embedder method reportStepdocs.

public void reportStepdocs(Configuration configuration, List<CandidateSteps> candidateSteps) {
    StepFinder finder = configuration.stepFinder();
    StepdocReporter reporter = configuration.stepdocReporter();
    List<Object> stepsInstances = finder.stepsInstances(candidateSteps);
    reporter.stepdocs(finder.stepdocs(candidateSteps), stepsInstances);
}
Also used : StepFinder(org.jbehave.core.steps.StepFinder) StepdocReporter(org.jbehave.core.reporters.StepdocReporter)

Aggregations

StepFinder (org.jbehave.core.steps.StepFinder)8 CandidateSteps (org.jbehave.core.steps.CandidateSteps)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 OutputStream (java.io.OutputStream)4 PrintStream (java.io.PrintStream)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)4 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)4 PrintStreamStepdocReporter (org.jbehave.core.reporters.PrintStreamStepdocReporter)4 Test (org.junit.Test)4 Configuration (org.jbehave.core.configuration.Configuration)3 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)3 FileNotFoundException (java.io.FileNotFoundException)2 Embedder (org.jbehave.core.embedder.Embedder)2 EmbedderControls (org.jbehave.core.embedder.EmbedderControls)2 SilentlyAbsorbingFailure (org.jbehave.core.failures.SilentlyAbsorbingFailure)2 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)2 StepdocReporter (org.jbehave.core.reporters.StepdocReporter)2 StoryReporterBuilder (org.jbehave.core.reporters.StoryReporterBuilder)2 InstanceStepsFactory (org.jbehave.core.steps.InstanceStepsFactory)2