Luckily, the StoryReporter interface gives us all the events we need to 
determine BeforeExample and AfterExample. I have created a hack / workaround 
for this but was not able to attach files to the Jira. I have created a new 
interface, StoryReporter2 which is delegated to by the StoryReporter2Adapter. 
This allows you to provide an implementation of StoryReporter2 that gets 
notifications for beforeExample / afterExample. This code goes some way to 
addressing the issues that I mention in 
http://jira.codehaus.org/browse/JBEHAVE-549 
<http://jira.codehaus.org/browse/JBEHAVE-549> . Please see the attached files.
 
 
Usage:
 
Format myFormat = new MyFormat();
 
Configuration configuration = new MostUsefulConfiguration()
 .useStoryReporterBuilder(
    new StoryReporterBuilder().withFormats(Format.CONSOLE, myFormat)
 .....
 );

public class MyStoryReporter2 extends NullStoryReporter2 {
   public void beforeExample(Story story, Scenario scenario, Map<String, 
String> tableRow) {
      // do stuff
   }
   public void afterExample(Story story, Scenario scenario, Map<String, String> 
tableRow) {
     // do stuff
   }
   // other events can be listened to here
}
 
public class MyFormat extends Format {
   public MyFormat() { 
      super("MYFORMAT"); 
   }
   public StoryReporter createStoryReporter(FilePrintStreamFactory factory, 
StoryReporterBuilder storyReporterBuilder) {
      return new StoryReporter2Adapter(new MyStoryReporter2());
   }
}
 
 
Cheers,
Lance.
 

________________________________

From: Andreas Ebbert-Karroum [mailto:andreas.ebbert-karr...@codecentric.de] 
Sent: 30 June 2011 10:12
To: user@jbehave.codehaus.org
Subject: Re: [jbehave-user] @BeforeExample und @AfterExample?


http://jira.codehaus.org/browse/JBEHAVE-548 

<http://jira.codehaus.org/browse/JBEHAVE-548> Andreas


Am 30. Juni 2011 11:03 schrieb Mauro Talevi <mauro.tal...@aquilonia.org>:


        Not at the moment. You can raise a jira issue for it.
        

        On 30 Jun 2011, at 10:45, Andreas Ebbert-Karroum 
<andreas.ebbert-karr...@codecentric.de> wrote:
        
        

                Hi, 

                is there a way to execute some steps before and after each 
example? scenario is sometimes not fine grained enough.
                
                
                -- 
                Mit freundlichen Grüßen / Best regards

                Andreas Ebbert-Karroum | Bereichsleiter der Agilen Software 
Factory
                
                codecentric AG | Merscheider Straße 1 | 42699 Solingen | 
Deutschland
                tel: +49 (0) 212.23362825 | fax: +49 (0) 212.23362879 | mobil: 
+49 (0) 175.2664109
                <http://www.codecentric.de> www.codecentric.de | 
<http://blog.codecentric.de> blog.codecentric.de | 
<http://www.meettheexperts.de> www.meettheexperts.de | <http://www.more4fi.de> 
www.more4fi.de
                
                Sitz der Gesellschaft: Düsseldorf | HRB 63043
                Vorstand: Klaus Jäger (Vorsitzender) | Mirko Novakovic . Rainer 
Vehns
                Aufsichtsrat: Patric Fedlmeier (Vorsitzender) . Bernd Klinkmann 
. Jürgen Schütz
                
                Diese E-Mail einschließlich evtl. beigefügter Dateien enthält 
vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der 
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den Absender und löschen Sie diese E-Mail und evtl. 
beigefügter Dateien umgehend. Das unerlaubte Kopieren, Nutzen oder Öffnen evtl. 
beigefügter Dateien sowie die unbefugte Weitergabe dieser E-Mail ist nicht 
gestattet.
                
                




-- 
Mit freundlichen Grüßen / Best regards

Andreas Ebbert-Karroum | Bereichsleiter der Agilen Software Factory

codecentric AG | Merscheider Straße 1 | 42699 Solingen | Deutschland
tel: +49 (0) 212.23362825 | fax: +49 (0) 212.23362879 | mobil: +49 (0) 
175.2664109
www.codecentric.de | blog.codecentric.de | www.meettheexperts.de | 
www.more4fi.de

Sitz der Gesellschaft: Düsseldorf | HRB 63043
Vorstand: Klaus Jäger (Vorsitzender) | Mirko Novakovic . Rainer Vehns
Aufsichtsrat: Patric Fedlmeier (Vorsitzender) . Bernd Klinkmann . Jürgen Schütz

Diese E-Mail einschließlich evtl. beigefügter Dateien enthält vertrauliche 
und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige 
Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie 
bitte sofort den Absender und löschen Sie diese E-Mail und evtl. beigefügter 
Dateien umgehend. Das unerlaubte Kopieren, Nutzen oder Öffnen evtl. beigefügter 
Dateien sowie die unbefugte Weitergabe dieser E-Mail ist nicht gestattet.


Attachment: StoryReporter2AdapterTest.java
Description: StoryReporter2AdapterTest.java

Attachment: StoryReporter2Adapter.java
Description: StoryReporter2Adapter.java

Attachment: StoryReporter2.java
Description: StoryReporter2.java

Attachment: NullStoryReporter2.java
Description: NullStoryReporter2.java

Visit our website at http://www.ubs.com 

This message contains confidential information and is intended only 
for the individual named. If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail. Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system. 

E-mails are not encrypted and cannot be guaranteed to be secure or 
error-free as information could be intercepted, corrupted, lost, 
destroyed, arrive late or incomplete, or contain viruses. The sender 
therefore does not accept liability for any errors or omissions in the 
contents of this message which arise as a result of e-mail transmission. 
If verification is required please request a hard-copy version. This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities 
or related financial instruments. 

UBS Limited is a company limited by shares incorporated in the United 
Kingdom registered in England and Wales with number 2035362. 
Registered office: 1 Finsbury Avenue, London EC2M 2PP.  UBS Limited 
is authorised and regulated by the Financial Services Authority. 

UBS AG is a public company incorporated with limited liability in 
Switzerland domiciled in the Canton of Basel-City and the Canton of 
Zurich respectively registered at the Commercial Registry offices in 
those Cantons with Identification No: CH-270.3.004.646-4 and having 
respective head offices at Aeschenvorstadt 1, 4051 Basel and 
Bahnhofstrasse 45, 8001 Zurich, Switzerland.  Registered in the 
United Kingdom as a foreign company with No: FC021146 and having a 
UK Establishment registered at Companies House, Cardiff, with No:  
BR 004507.  The principal office of UK Establishment: 1 Finsbury Avenue, 
London EC2M 2PP.  In the United Kingdom, UBS AG is authorised and 
regulated by the Financial Services Authority.

UBS reserves the right to retain all messages. Messages are protected 
and accessed only in legally justified cases. 
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to