Hello everyone,

_I_ have no problems with doing this, I was just suggesting a solution
(via maven-antrun-plugin) for starting/stopping a server before resp.
after the jbehave run :-).

Regards
Mirko
Regards Mirko
--
http://illegalstateexception.blogspot.com/
https://github.com/mfriedenhagen/
https://bitbucket.org/mfriedenhagen/


On Wed, Sep 25, 2013 at 10:32 AM, louis gueye <[email protected]> wrote:
> Hi Mirko,
>
> I thing you should drive the execution flow with maven and not jbehave so
> that starting server, stopping server and executing jbehave is bound to
> maven lifecycle respectively pre-integration-test, post-integration-test and
> integration-test.
>
> There are many resource on the web explaining how to do that.
> This is one version on my blog
>
> Hope this helps.
>
>
>
> Cordialement/Regards,
>
> Louis GUEYE
> linkedin | blog | twitter
>
>
> 2013/9/25 Mirko Friedenhagen <[email protected]>
>>
>> Hello Mauro,
>>
>> I was just trying to reply to Corbin's requirements (maybe I
>> misunderstood these, though):
>> - He needs to start a server *before* executing his story and needs to
>> stop it securely afterwards, so he is asking for a fixture like this:
>> --- snip ---
>> startServer();
>> try {
>>   checkStoryByRunningJBehave()
>> } finally {
>>   stopServer();
>> }
>> --- snap ---
>> - It is my understanding, that when a step fails in JBehave, the
>> following steps will *not* be executed, so stopServer() would not be
>> executed.
>>
>> Regards
>> Mirko
>>
>> Regards Mirko
>> --
>> http://illegalstateexception.blogspot.com/
>> https://github.com/mfriedenhagen/
>> https://bitbucket.org/mfriedenhagen/
>>
>>
>> On Tue, Sep 24, 2013 at 7:26 PM, Mauro Talevi
>> <[email protected]> wrote:
>> > Not clear what you're asking. Can you please reformulate and provide an
>> > example?
>> >
>> > On 24 Sep 2013, at 16:42, Mirko Friedenhagen <[email protected]>
>> > wrote:
>> >
>> >> Hello Mauro,
>> >>
>> >> start/stop of the server should probably a fixture. How do you enforce
>> >> that the step stopping the server is really executed?
>> >>
>> >> @Corbin: a really dirty way would be to use the maven-antrun-plugin
>> >> with two executions and via the java-Task execute the static methods
>> >> for startup and shutdown during the phases pre-integration-test and
>> >> post-integration-test (You could do this with two helper classes using
>> >> the main-method). Something like (of course completely untested) in
>> >> //project/build/plugins:
>> >> --- snip ---
>> >>            <plugin>
>> >>                <groupId>org.apache.maven.plugins</groupId>
>> >>                <artifactId>maven-antrun-plugin</artifactId>
>> >>                <version>1.7</version>
>> >>                <executions>
>> >>                    <execution>
>> >>                        <phase>pre-integration-test</phase>
>> >>                        <id>start-my-server</id>
>> >>                        <configuration>
>> >>                            <target>
>> >>                                <property name="maven.test.classpath"
>> >> -                                          refid="maven.test.classpath"
>> >> />
>> >>                                <java failonerror="true" fork="true"
>> >>
>> >> classpath="${maven.test.classpath}"
>> >>
>> >> classname="org.example.ServerStart"
>> >>                                      />
>> >>                            </target>
>> >>                        </configuration>
>> >>                        <goals>
>> >>                            <goal>run</goal>
>> >>                        </goals>
>> >>                    </execution>
>> >>                    <execution>
>> >>                        <phase>post-integration-test</phase>
>> >>                        <id>stop-my-server</id>
>> >>                        <configuration>
>> >>                            <target>
>> >>                                <property name="maven.test.classpath"
>> >> -                                          refid="maven.test.classpath"
>> >> />
>> >>                                <java failonerror="true" fork="true"
>> >>
>> >> classpath="${maven.test.classpath}"
>> >>                                      classname="org.example.ServerStop"
>> >>                                      />
>> >>                            </target>
>> >>                        </configuration>
>> >>                        <goals>
>> >>                            <goal>run</goal>
>> >>                        </goals>
>> >>                    </execution>
>> >>                </executions>
>> >>            </plugin>
>> >> --- snap ---
>> >> Now you should tell jbehave *not* to fail otherwise
>> >> post-integration-test will not be run.
>> >>
>> >> Regards
>> >> Mirko
>> >> Regards Mirko
>> >> --
>> >> http://illegalstateexception.blogspot.com/
>> >> https://github.com/mfriedenhagen/
>> >> https://bitbucket.org/mfriedenhagen/
>> >>
>> >>
>> >> On Tue, Sep 24, 2013 at 4:45 PM, Mauro Talevi
>> >> <[email protected]> wrote:
>> >>> What's wrong with a dedicated steps class for the start/stop
>> >>> operations?
>> >>> They are annotated methods, and thus steps, just as well.
>> >>>
>> >>> The JUnitStories class is only meant to configure and execute stories,
>> >>> not
>> >>> to hold executable methods.  It also provides the hook for IDEs which
>> >>> support JUnit.
>> >>>
>> >>> The Maven plugin knows nothing of JUnit and its annotations.   If
>> >>> you're
>> >>> trying to go down this route you're likely to hit a brick wall.
>> >>>
>> >>> Cheers
>> >>>
>> >>> On 24 Sep 2013, at 15:18, "Corbin, J.D." <[email protected]>
>> >>> wrote:
>> >>>
>> >>> 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.
>> >>
>> >> ---------------------------------------------------------------------
>> >> 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
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> 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