As it turns out, we don't.  We are starting and stopping a server that is
required by our BDD scenarios and didn't want to put that logic in any step
classes.  The logical place to manage the starting and stopping of the
server, we believed, was in our class that extends JUnitStories.  We had
hoped there were some annotated lifecycle methods we could use for this,
and in fact did find that the JUnit @BeforeClass and @AfterClass methods
worked but only when you run the JUnitStories derived class as JUnit.  I
couldn't figure out how to configure the JBEHAVE-MAVEN-PLUGIN to run the
class as a JUnit like we do in Eclipse.

For now, we can construct and start the server in the constructor of the
aforementioned class.  THe shutdown of the server will happen when the JVM
goes away.  This is not ideal but will work for us.

So, we could use the JUnit specific annotations if we could get them to
execute when running our JUnitStories class via the maven plugin.




On Mon, Sep 23, 2013 at 4:50 PM, Mauro Talevi <[email protected]>wrote:

> Why do need to put the before/after methods in Embeddable class and not in
> a steps class?
>
> On 23 Sep 2013, at 22:39, "Corbin, J.D." <[email protected]> wrote:
>
> Hi, that does work for an InstanceStepsFactory, but we are using a
> GuiceStepsFactory.  I'll have to see if there is a way to extend this
> factory to support this.
>
>
>
> On Mon, Sep 23, 2013 at 3:29 PM, Mauro Talevi 
> <[email protected]>wrote:
>
>> The JBehave lifecycle annotations must found in the steps classes. That
>> said, you can register your class as a steps class.   Just pass the "this"
>> reference to the InstanceStepsFactory.
>>
>> On 23 Sep 2013, at 21:35, "Corbin, J.D." <[email protected]> wrote:
>>
>> I have a class that extends JUnitStories and specifies two methods that
>> use the JUnit specific annotations @BeforeClass @AfterClass.  Inside of
>> these methods I do some initialization for my test scenarios, like propping
>> up a test server.   So the BeforeClass method starts the server and the
>> AfterClass method shuts down the server.
>>
>> When I run the class that extends JUnitStories as a JUnit test, it
>> executes the methods annotated with the beforeclass and afterclass just as
>> you might expect.  All scenarios execute and succeed when running in this
>> manner.
>>
>> Now, when I run using maven (command line) and the jbehave-maven-plugin,
>> the JUnit (not really surprising) specific annotations are not executed and
>> therefore my server startup and shutdown logic is bypassed which prevents
>> my scenarios from executing.
>>
>> How can I run the JBehave scenarios from the command line using Maven
>> such that my JUnit (or JBehave specific) annotated methods get executed?
>>
>> I have tried using JBehave specific annotations like @BeforeStories,
>> @AfterStories,@BeforeTest, and @AfterTest (as well) in my class that
>> extends JUnitStories, but none of the methods with these annotations ever
>> get executed, either when running in Eclipse (as JUnit), nor Maven.
>>
>> Any suggestions would greatly be appreciated.
>>
>>
>

Reply via email to