- Revision
- 1235
- Author
- mauro
- Date
- 2009-09-08 07:53:12 -0500 (Tue, 08 Sep 2009)
Log Message
Added test to show how output message patterns can be customised.
Modified Paths
Diff
Modified: trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java (1234 => 1235)
--- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java 2009-09-08 11:23:36 UTC (rev 1234) +++ trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/reporters/PrintStreamScenarioReporterBehaviour.java 2009-09-08 12:53:12 UTC (rev 1235) @@ -70,4 +70,36 @@ } + @Test + public void shouldOutputStepsAndResultToPrintStreamWithCustomPatterns() { + IllegalAccessException exception = new IllegalAccessException("Leave my money alone!"); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ScenarioReporter reporter = new PrintStreamScenarioReporter(new PrintStream(out)){ + + @Override + protected String patternFor(String key, String defaultPattern) { + if ( key.equals("pending") ){ + return "{0} (NOT YET IMPLEMENTED)"; + } else if ( key.equals("failed") ){ + return "{0} <<< FAILED"; + } else if ( key.equals("notPerformed") ){ + return "{0} (NOT EXECUTED DUE TO PENDING)"; + } + return defaultPattern; + } + + }; + reporter.successful("Given I have a balance of $50"); + reporter.successful("When I request $20"); + reporter.failed("When I ask Liz for a loan of $100", exception); + reporter.pending("Then I should have a balance of $30"); + reporter.notPerformed("Then I should have $20"); + + ensureThat(out.toString(), equalTo( + "Given I have a balance of $50" + NL + + "When I request $20" + NL + + "When I ask Liz for a loan of $100 <<< FAILED" + NL + + "Then I should have a balance of $30 (NOT YET IMPLEMENTED)" + NL + + "Then I should have $20 (NOT EXECUTED DUE TO PENDING)" + NL)); + } }
To unsubscribe from this list please visit:
