Hi Barbara,

you can define a reporter that delegate to multiple custom reporters -
one for CONSOLE and one for TXT file.   Example configuration to output
failure cause is:

            public ScenarioReporter forReportingScenarios() {
                return new ScenarioReporterBuilder(new
FilePrintStreamFactory(scenarioClass, resolver)){
                     public ScenarioReporter reporterFor(Format format){
                         switch (format) {
                             case CONSOLE:
                                  return
reporterWithFailureCause(System.out);
                             case TXT:
                                 factory.useConfiguration(new
FileConfiguration("txt"));
                                 return
reporterWithFailureCause(factory.getPrintStream());
                               default:
                                 return super.reporterFor(format);
                         }
                     }

                    private ScenarioReporter
reporterWithFailureCause(final PrintStream output){                   
       
                        final Properties outputPatterns = new Properties();
                        final KeyWords keywords = new I18nKeyWords();
                        return new PrintStreamScenarioReporter(output,
outputPatterns, keywords, true){
                           public void failed(String step, Throwable
cause) {
                                print(format("failed", "{0}
({1})\n({2})\n", step, keywords.failed(), cause));
                            }
                        };
                    }                   
                }
                .outputTo("target/jbehave-reports").outputAsAbsolute(true)
                .withDefaultFormats()
                .with(CONSOLE).with(TXT)
                .build();


This configuration will output failed steps like:

Then the traders returned are:
|name|rank|
|Moe|Stooge 1| (FAILED)
(junit.framework.ComparisonFailure: null
expected:<[Trader[name=[Moe,rank=Stooge 1],stocks=[]]]> but
was:<[Trader[name=[Curly,rank=Stooge 2,stocks=[]],
Trader[name=Larry,rank=Stooge 3],stocks=[]]]>)

i.e.
<the step text> (FAILED)
(the failure cause)

Note that the content of the failure message is completely in you hands
and in is in plain text.  If you use a matchers framework like JUnit or
Hamcrest, the failure message will be something like above.

>From 3.x we've introduced the concept of OutcomesTable which can display
in a tabular format multiple outcomes, some of which may be verified and
some may not.

Cheers

On 10/06/2010 14:42, Barbara Rosi-Schwartz wrote:
> Ok Mario, I now have the following configuration:
>
> private static final Configuration configuration = new 
> MostUsefulConfiguration() {
>       @Override
>       public ScenarioReporter forReportingScenarios() {
>          return new PrintStreamScenarioReporter(System.out, new Properties(), 
> keywords(), true);
>       }
>    };
>
> What I now would like to do are two things:
> 1) have my PrintStreamScenarioReporter report not just to the console, but 
> also to a file
> 2) have it report FAILURE - expected A but got when a failure occurs. A 
> question that I have about this is: in one of your replies below you say: 
> "Note that "expected A but got B" here would have to be the failure exception 
> message, as generated by say a matcher assert invocation.". Does this mean 
> that all I would get in my report would be "expected true but got false"? 
> What I am really after are the values that are being compared, not the 
> outcome of the comparison.
>
> How do I modify the config above to achieve these two goals?
>
> Thanks again,
> B.
>
>   



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to