Search in sources :

Example 1 with PrintStreamStepdocReporter

use of org.jbehave.core.reporters.PrintStreamStepdocReporter in project jbehave-core by jbehave.

the class EmbedderBehaviour method shouldReportNoMatchingStepdocsFoundWhenNoStepsProvided.

@Test
public void shouldReportNoMatchingStepdocsFoundWhenNoStepsProvided() {
    // Given
    Embedder embedder = new Embedder();
    embedder.useCandidateSteps(asList(new CandidateSteps[] {}));
    embedder.configuration().useStepFinder(new StepFinder());
    OutputStream out = new ByteArrayOutputStream();
    embedder.configuration().useStepdocReporter(new PrintStreamStepdocReporter(new PrintStream(out)));
    // When
    embedder.reportMatchingStepdocs("Given a non-defined step");
    // Then
    String expected = "Step 'Given a non-defined step' is not matched by any pattern\n" + "as no steps instances are provided\n";
    assertThat(dos2unix(out.toString()), equalTo(expected));
}
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 2 with PrintStreamStepdocReporter

use of org.jbehave.core.reporters.PrintStreamStepdocReporter in project jbehave-core by jbehave.

the class EmbedderBehaviour method shouldFindAndReportMatchingSteps.

@Test
public void shouldFindAndReportMatchingSteps() {
    // 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.reportMatchingStepdocs("Given a given");
    // Then
    String expected = "Step 'Given a given' is matched by annotated patterns:\n" + "'Given a given'\n" + "org.jbehave.core.embedder.EmbedderBehaviour$MySteps.given()\n" + "from steps instances:\n" + "org.jbehave.core.embedder.EmbedderBehaviour$MySteps\n";
    assertThat(dos2unix(out.toString()), equalTo(expected));
}
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 3 with PrintStreamStepdocReporter

use of org.jbehave.core.reporters.PrintStreamStepdocReporter in project jbehave-core by jbehave.

the class EmbedderBehaviour method shouldReportNoMatchingStepdocsFoundWithStepProvided.

@Test
public void shouldReportNoMatchingStepdocsFoundWithStepProvided() {
    // 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.reportMatchingStepdocs("Given a non-defined step");
    // Then
    String expected = "Step 'Given a non-defined step' is not matched by any pattern\n" + "from steps instances:\n" + "org.jbehave.core.embedder.EmbedderBehaviour$MySteps\n";
    assertThat(dos2unix(out.toString()), equalTo(expected));
}
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 4 with PrintStreamStepdocReporter

use of org.jbehave.core.reporters.PrintStreamStepdocReporter 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)

Aggregations

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 CandidateSteps (org.jbehave.core.steps.CandidateSteps)4 StepFinder (org.jbehave.core.steps.StepFinder)4 Test (org.junit.Test)4