Mauro Talevi | 1 Feb 09:35

Re: Not ignoring failures in GivenStories

Hi Carlos, 

to control execution upon pending steps, you should configure the 
appropriate PendingStepStrategy via the Configuration:

http://jbehave.org/reference/stable/pending-steps.html

So, choose FailingUponPendingStep if you want to stop execution without 
ignoring failures in stories.

Cheers

On Tue Jan 31 20:29:50 2012, Carlos Silva wrote:
> Hi I'm trying to stop the execution of my story steps (mark as 
> pending) whenever there is a failure in any of my GivenStories I know 
> that I can set doIgnoreFailureInStories to true but this will not run 
> all my other stand alone stories and I only want to stop execution 
> when any given story fails. Any help appreciated.

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

    http://xircles.codehaus.org/manage_email

Craig Tataryn | 6 Feb 17:05

Re: JBehave and Spring Transactions...

Carlus Henry <carlushenry@...> writes:

> 
> 
> Brian....
> 
> Thanks once again.  I will look into the TransactionalTestExecutionListener. 
 You also make valid points about using a fresh database and examining the 
resource strategy as well.
> 
> Thanks again...
> 
> On Mon, Jan 3, 2011 at 3:30 PM, Brian Repko <brian.repko-
wfCUzQxgNmFCG57dx6KWINBPR1lH4CV8@...> wrote:
> 
> 
>  
> Carlus, 
>  
> Look at Spring's 
org.springframework.test.context.transaction.TransactionalTestExecutionListenerI
'm not sure that you need to do the  <at> BeforeTransaction /  <at> 
AfterTransaction logic - perhaps
> you would - but that code should be the basis of your code - the 
beforeTestMethod and
> afterTestMethod should be like BeforeScenario and AfterScenario.
> 
> I'm assuming that you'll always rollback.
> 
> In terms of the resource setup strategy - I get that that might be a 
(Continue reading)

Picon
Favicon

Re: How to make Surefire to see embedder-based tests as JUnit tests?

On 2012-01-20 21:03, Marcin Zajączkowski wrote:
> Hi,
> 
> I would like to have a JBehave tests run via maven surefire plugin as the simple JUnit tests. By default
surefire doesn't recognize my test classes as JUnit tests. In case of extending JUnitStory/Stories I
could override run method and add @Test annotation, but what can I do using embedder-based method like below?

Just for groups archive readers. I modified it to implements Embeddable
and use SpringAnnotatedEmbedderRunner and it works fine as a JUnit test
from Maven.

Marcin

> 
> @RunWith(SpringAnnotatedPathRunner.class)
> @Configure
> @UsingEmbedder
> @UsingSpring(resources = {...})
> @UsingPaths
> public class MyStoriesTest {
> }
> 
> Regards
> Marcin
> 

--

-- 
http://blog.solidsoft.info/ - Working code is not enough

---------------------------------------------------------------------
(Continue reading)

Craig Tataryn | 6 Feb 19:19

Re: JBehave and Spring Transactions...

Craig Tataryn <craiger@...> writes:
> I'm having a very similar problem and I just can't figure out how to get my 
> Spring transactions working across all my steps.  My situation is this:
> 
> * I have a Stories class which uses a SpringJUnit4ClassRunner: 
> https://gist.github.com/1752773
> * The embedder class looks like so: https://gist.github.com/1752899
> * I have a Steps class which inserts some data into a table via a JdbcTemplate 
> and uses my Service class to read back the data using JPA: 
> https://gist.github.com/1752795
> 
> SNIP...

P.P.S. If I isolate my test outside of jBehave, everything works great (i.e. 
https://gist.github.com/1753833).  The JdbcTemplate code participates in the 
same transaction as the Service-level JPA code just like it should.

I'm stumped...

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

    http://xircles.codehaus.org/manage_email

Craig Tataryn | 6 Feb 20:12

Re: JBehave and Spring Transactions...

Craig Tataryn <craiger@...> writes:

> P.P.S. If I isolate my test outside of jBehave, everything works great (i.e. 
> https://gist.github.com/1753833).  The JdbcTemplate code participates in the 
> same transaction as the Service-level JPA code just like it should.
> 
> I'm stumped...
> 

Analysing the log files between the working test and the JBehave test I can see
the problem.  Spring binds its transaction manager to the "main" thread
in both instances, however in the case of the JBehave test, the steps are
executed in a another thread ("pool-1-thread-1" to be precise) and thus no
transaction manager exists so a new one is created on-demand.

Is there a way I can work around this problem?  Can I have steps execute within
the main thread instead of within the pool?

Craig.

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

    http://xircles.codehaus.org/manage_email

Craig Tataryn | 6 Feb 21:23

Re: JBehave and Spring Transactions...

Craig Tataryn <craiger@...> writes:

> 
> Craig Tataryn <craiger@...> writes:
> 
> > P.P.S. If I isolate my test outside of jBehave, everything works great (i.e. 
> > https://gist.github.com/1753833).  The JdbcTemplate code participates in the 
> > same transaction as the Service-level JPA code just like it should.
> > 
> > I'm stumped...
> > 
> 
> Analysing the log files between the working test and the JBehave test I can 
see
> the problem.  Spring binds its transaction manager to the "main" thread
> in both instances, however in the case of the JBehave test, the steps are
> executed in a another thread ("pool-1-thread-1" to be precise) and thus no
> transaction manager exists so a new one is created on-demand.
> 
> Is there a way I can work around this problem?  Can I have steps execute 
within
> the main thread instead of within the pool?
> 
> Craig.
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
(Continue reading)

Brian Repko | 6 Feb 21:49
Favicon
Gravatar

Re: Re: JBehave and Spring Transactions...


Craig,

It depends on how you run the tests.

If you are using JUnit annotations (@RunsWith(SpringJUnit4ClassRunner)), then you need to run with JUnit.

If you are running with JBehave - then it runs the embedder on its own.  It will not use that JUnit annotation.
There are JBehave annotations for that.

Also when you mark the Steps class as @Transactional, Spring will create a proxy and the
@Given/@When/@Then annotated methods are not found anymore on the proxy.
A couple of folks have asked about that.  It might depend on how you weave the class (AspectJ vs Spring-AOP).

Also, I don't get your setup.  Your Services should be @Transactional.
Your Steps classes are clients to those services.  If you make the steps transactional and they rollback,
then you won't have data for your Thens. no?
And making your Stories class @Transactional makes me think that you will run the whole suite as a
transaction which could be huge transaction log at the database level and hugely slow.

Stories / Steps should be clients to the system under test including its transactional logic.

Brian

----- Original message -----
From: "Craig Tataryn" <craiger@...>
To: user@...
Date: Mon, 6 Feb 2012 16:05:53 +0000 (UTC)
Subject: [jbehave-user] Re: JBehave and Spring Transactions...

(Continue reading)

Craig Tataryn | 7 Feb 20:52

Re: JBehave and Spring Transactions...

Brian Repko <brian.repko@...> writes:

> 
> 
> Craig,
> 
> 
> Also when you mark the Steps class as @Transactional, Spring will create a 
proxy and the
> @Given/@When/@Then annotated methods are not found anymore on the proxy.
> A couple of folks have asked about that.  It might depend on how you weave the 
class (AspectJ vs Spring-AOP).

Ahhhh, makes sense now.

> 
> Also, I don't get your setup.  Your Services should be @Transactional.
> Your Steps classes are clients to those services.  If you make the steps 
transactional and they rollback,
> then you won't have data for your Thens. no?
> And making your Stories class @Transactional makes me think that you will run 
the whole suite as a
> transaction which could be huge transaction log at the database level and 
hugely slow.

My services are annotated with @Transactional.  You are correct though, I do 
want the steps to all operate within the same Transaction that my JUnit test 
creates.  This way, I can seed data into the database before my stories run, 
have my services invoked by the steps munge data at will, etc...  Then, when the 
test is over it just rolls back in the traditional SpringJUnit4ClassRunner way.
(Continue reading)

Brian Repko | 7 Feb 21:21
Favicon
Gravatar

Re: Re: JBehave and Spring Transactions...


Craig,

You may find situations with transactions done that way where the software
doesn't perform the same as the test.

If you're interested, the spring-security examples restore the state of the
database for every story by using DbUnit, just to give you another option.

Brian

----- Original message -----
From: "Craig Tataryn" <craiger@...>
To: user@...
Date: Tue, 7 Feb 2012 19:52:41 +0000 (UTC)
Subject: [jbehave-user] Re: JBehave and Spring Transactions...

Brian Repko <brian.repko@...> writes:

> 
> 
> Craig,
> 
> 
> Also when you mark the Steps class as @Transactional, Spring will create a 
proxy and the
> @Given/@When/@Then annotated methods are not found anymore on the proxy.
> A couple of folks have asked about that.  It might depend on how you weave the 
class (AspectJ vs Spring-AOP).

(Continue reading)

Brian Repko | 10 Feb 15:52
Favicon
Gravatar

Change '<' and '>' for parameter replacement?

 
JBehave users:
 
I can't seem to find how the '<' and '>' characters get used/configured for parameter replacement in parameterized scenarios / Composites.
Is that just convention - whatever is in the story has to match what is in the annotation value? Or is that configurable somehow?
 
Thanks!
Brian

Gmane