I am now able to output all fails / pending to a file.  Now I need to
output passing scenarios to a file.

In PrintStreamScenarioReporter.java...

    public PrintStreamScenarioReporter() {
        //this(System.out);
         this(getPrintStream());
    }

  private static PrintStream getPrintStream() {
        try
        {
           String fileContents = "";
            File file = new File("TestOutput.txt");
            if (file.exists()){
                    FileInputStream fis = null;
                    BufferedInputStream bis = null;
                    DataInputStream dis = null;
                    String newline = System.getProperty("line.separator");
        
                    try {
                      fis = new FileInputStream(file);
                      bis = new BufferedInputStream(fis);
                      dis = new DataInputStream(bis);
                      while (dis.available() != 0) {
                        fileContents= fileContents + dis.readLine() + newline;
                      }
                      bis.close();
                      dis.close();
        
                    } catch (FileNotFoundException e) {
                      e.printStackTrace();
                    } catch (IOException e) {
                      e.printStackTrace();
                    }
            }

            PrintStream out = new PrintStream(new
FileOutputStream("TestOutput.txt"));
            out.print(fileContents);

            return  out;
        }
        catch (Exception e) { return System.out; }
    }


Now I'd also like to output to multiple files....
any suggestions?  Maybe after a story's scenarios are done writing the
file is renamed appropriately to describe the story?

Any suggestions?

Laura

On Thu, Feb 26, 2009 at 8:56 PM, Laura Vendramini <[email protected]> wrote:
> Hey Mauro,
>
> I looked at the ReportCanBeWrittenToFile.java file and the Trader
> example.  I tried to configure my scenario class to act the same as
> ReportCanBeWrittenToFile but  it looks like I'll need 3 additional
> files ( Converter (ie TraderConverter.java) file and
> a Persister type file (TraderPersister.java),  and the Scenario
> Reporter) per story to output to a file.  I can't use this method
> since my team is going to have around 100 stories.  Does that make
> sense?
> I want to output just like the Trader example scenario
> "ReportCanBeWrittenToFile" but on a large scale project with multiple
> stories and scenarios.  I also want to output passing scenarios.
>
> Basically I tried ReportCanBeWrittenToFile story and want the same
> output (plus passing scenarios), but need a way to get this without
> having to rely on making a converter file (ie TraderConverter) and a
> Persister file.
>
> Do you know how I can give this??
>
> Dan suggested doing...
>
> new MostUsefulConfiguration() {
>
>  PrintStream out; // one instance for the whole run
>
>  { // anonymous constructor block
>    try {
>      out = new PrintStream(new FileOutputStream("TestOutput.txt"));
>  } catch (Exception e) {
>    throw new RuntimeException(e);
>  }
>
>  public ScenarioReporter forReportingScenarios() {
>       return out;
>   }
> };
>
> But I have no idea where he would insert this within the code....I
> tried playing around with it, but was unsuccessful.
>
> Any ideas??
>
> Thanks so much!
>
> Laura
>
>
> On Thu, Feb 26, 2009 at 7:46 PM, Mauro Talevi
> <[email protected]> wrote:
>> Laura Vendramini wrote:
>>>
>>> Hey Chandru,
>>>
>>> Sounds like I am trying to do the same thing as you.  I tried the
>>> trader sample and it was able to output to a file in the tmp
>>> directory.  I tried migrating the changes over to my code but it looks
>>> like 3 additional files ( Converter (ie TraderConverter.java) file and
>>> a Persister type file (TraderPersister.java),  and the Scenario
>>> Reporter) are needed per story to output to a file.  I can't use this
>>> method since my team is going to have around 100 stories.  That means
>>> at least 300 additional classes...
>>>
>>> Anyone know a better way to output to a file or create a summary
>>> report with maven 2?
>>>
>>
>> First of all, apologies for the wrong URL - core has moved now and the
>> correct URL is:
>>
>> https://svn.codehaus.org/jbehave/trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/ReportCanBeWrittenToFile.java
>>
>> Secondly, this examples shows out to create a bespoke configuration that
>> allow to write scenario to a file.  If you define a base scenario, e.g.
>> MyProjectScenario that uses this configuration and then extend this scenario
>> in your stories, you'll be able to write all the output to same  file (or
>> easily extend just the filename of the output to differ for each story if
>> you prefer).
>>
>> Have I misunderstood your usecase?  If so, please feel free to give more
>> details of the expected summary report.  This is a feature that we know we
>> can improve on.
>>
>> Cheers
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>   http://xircles.codehaus.org/manage_email
>>
>>
>>
>

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

    http://xircles.codehaus.org/manage_email


Reply via email to