[jbehave-user] Re: Can I reuse stories with two different implementations?
Got it! I reviewed the "parametrised.story" in the Trader JBehave example for the answer. It would nice if the JBehave documentation expressed this information. Here's how it is working right now (sans code clean-up): root.story Scenario: description GivenStories: scripts/requirement1.story#{0}, scripts/requirement1.story#{1} this file unless those steps are in here. Requires more investigation.> Examples: |protocol| |http | |jms| requirement1.story Scenario: description Given I use When ... Steps.java @Given("I use ") public void iUse(@Named("protocol") String protocol) { // this code is called twice. Once where "protocol=http", and once where "protocol=jms" } While I'm still not entirely comfortable with expressing transport protocols in my behaviors, this solution avoids duplicating stories for each new protocol. Thanx for your help Mauro. - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
[jbehave-user] Re: Can I reuse stories with two different implementations?
On 1/5/12 11:14 AM, Sheldon wrote: On 1/5/12 10:10 AM, Sheldon wrote: On 1/4/12 3:09 PM, Mauro Talevi wrote: Hi Sheldon, the recommended way to approach your problem would be to inject both service builder impls and then have a parameter to determine which is going to be used. E.g. Given I use the [HTTP or JMS] protocol The protocol would be stored in a member variable and use to return the appropriate instance of your service API. Then you can use parametrised scenarios to run the entire scenario with different values of the protocol. http://jbehave.org/reference/stable/parametrised-scenarios.html Cheers On 04/01/2012 19:37, Sheldon wrote: I am using JBehave in a project where we test http requests to web services. This has worked beautifully so far. Now the team is introducing a new front end using JMS. It is designed to work as a secondary front end to the existing web services. For example, a customer can post a request directly to the web service via http GET or POST, or alternatively submit a message to the JMS service, which then will submit an http GET or POST to the web service. The JMS service gives us the ability to prioritize and pre/post-process requests, which is why it is being introduced. I built the tests so that we have a collection of story files & a single steps file. The steps file includes the following: public class StepsFile { MyService service; ServiceBuilder serviceBuilder; [a collection of @Given, @When, @Then methods] } The ServiceBuilder generates the service object at the appropriate time during testing. 'service' is then queried for results (within @Then steps). Now that we need to handle two variations of MyService (http and JMS), can I configure JBehave to run thru the same stories twice, but injecting different versions of ServiceBuilder in to the StepsFile class for each iteration? Is there a better way to handle this kind of implementation variation? - 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 Actually, I think the 'Parametrized Stories' feature would work. This way I would not have to duplicate stories just because we support a new protocol. The documentation on it is unclear on how to leverage the parameter that is passed in to the story. Does someone know where I can find a working example of this feature? - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email I found a problem with using parametrized stories to solve the problem. The example on the JBehave site states that a parametrized story should be identified using the following syntax: GivenStories: path/to/precondition.story#{0} The problem is that the stories are not packaged in the JAR because the reside under the test folder. To run them we use: public class Stories extends JUnitStories { ... @Override protected List storyPaths() { return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()), "**/*.story", "**/excluded*.story"); ... } The folder structure is: -stories - scripts - requirement1.story - requirement2.story - steps -Steps.java - Stories.java The key difference is that other users of this code will have different paths to the stories folder: /user//stories Can I make GivenStories work with this set up? - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email Some success. I had to change the path to match my maven build "target/test-classes" folder. So my story looks like this: GivenStories: scripts/requirement1.story#{0}, scripts/requirement1.story#{1} Examples: |protocol| |http| |jms| The requirement1 story looks like this: Scenario: description Given I use When ... And Steps.java looks like this: @Given ("I use $protocol") public void iUse(String protocol) { String that = protocol; } However, in IUse(), protocol reads "". I am missing something to get "http" and "jms". Any ideas what I am missing? - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
[jbehave-user] Re: Can I reuse stories with two different implementations?
On 1/5/12 10:10 AM, Sheldon wrote: On 1/4/12 3:09 PM, Mauro Talevi wrote: Hi Sheldon, the recommended way to approach your problem would be to inject both service builder impls and then have a parameter to determine which is going to be used. E.g. Given I use the [HTTP or JMS] protocol The protocol would be stored in a member variable and use to return the appropriate instance of your service API. Then you can use parametrised scenarios to run the entire scenario with different values of the protocol. http://jbehave.org/reference/stable/parametrised-scenarios.html Cheers On 04/01/2012 19:37, Sheldon wrote: I am using JBehave in a project where we test http requests to web services. This has worked beautifully so far. Now the team is introducing a new front end using JMS. It is designed to work as a secondary front end to the existing web services. For example, a customer can post a request directly to the web service via http GET or POST, or alternatively submit a message to the JMS service, which then will submit an http GET or POST to the web service. The JMS service gives us the ability to prioritize and pre/post-process requests, which is why it is being introduced. I built the tests so that we have a collection of story files & a single steps file. The steps file includes the following: public class StepsFile { MyService service; ServiceBuilder serviceBuilder; [a collection of @Given, @When, @Then methods] } The ServiceBuilder generates the service object at the appropriate time during testing. 'service' is then queried for results (within @Then steps). Now that we need to handle two variations of MyService (http and JMS), can I configure JBehave to run thru the same stories twice, but injecting different versions of ServiceBuilder in to the StepsFile class for each iteration? Is there a better way to handle this kind of implementation variation? - 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 Actually, I think the 'Parametrized Stories' feature would work. This way I would not have to duplicate stories just because we support a new protocol. The documentation on it is unclear on how to leverage the parameter that is passed in to the story. Does someone know where I can find a working example of this feature? - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email I found a problem with using parametrized stories to solve the problem. The example on the JBehave site states that a parametrized story should be identified using the following syntax: GivenStories: path/to/precondition.story#{0} The problem is that the stories are not packaged in the JAR because the reside under the test folder. To run them we use: public class Stories extends JUnitStories { ... @Override protected List storyPaths() { return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()), "**/*.story", "**/excluded*.story"); ... } The folder structure is: -stories - scripts - requirement1.story - requirement2.story - steps -Steps.java - Stories.java The key difference is that other users of this code will have different paths to the stories folder: /user//stories Can I make GivenStories work with this set up? - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Re: [jbehave-user] Re: Can I reuse stories with two different implementations?
If you want to run the same story but passing in a different parameter for each run, one option to create a new uber-story that executes the stories as given stories. http://jbehave.org/reference/stable/given-stories.html Something along these lines: Scenario: A scenario that verifies the same functionality for different protocols GivenStories: path/to/your.story#{0}, path/to/your.story#{1} Then ... // verify success or print message Examples: |Protocol| |http| |jms| On Thu Jan 5 18:10:10 2012, Sheldon wrote: Actually, I think the 'Parametrized Stories' feature would work. This way I would not have to duplicate stories just because we support a new protocol. The documentation on it is unclear on how to leverage the parameter that is passed in to the story. Does someone know where I can find a working example of this feature? - 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
[jbehave-user] Re: Can I reuse stories with two different implementations?
On 1/4/12 3:09 PM, Mauro Talevi wrote: Hi Sheldon, the recommended way to approach your problem would be to inject both service builder impls and then have a parameter to determine which is going to be used. E.g. Given I use the [HTTP or JMS] protocol The protocol would be stored in a member variable and use to return the appropriate instance of your service API. Then you can use parametrised scenarios to run the entire scenario with different values of the protocol. http://jbehave.org/reference/stable/parametrised-scenarios.html Cheers On 04/01/2012 19:37, Sheldon wrote: I am using JBehave in a project where we test http requests to web services. This has worked beautifully so far. Now the team is introducing a new front end using JMS. It is designed to work as a secondary front end to the existing web services. For example, a customer can post a request directly to the web service via http GET or POST, or alternatively submit a message to the JMS service, which then will submit an http GET or POST to the web service. The JMS service gives us the ability to prioritize and pre/post-process requests, which is why it is being introduced. I built the tests so that we have a collection of story files & a single steps file. The steps file includes the following: public class StepsFile { MyService service; ServiceBuilder serviceBuilder; [a collection of @Given, @When, @Then methods] } The ServiceBuilder generates the service object at the appropriate time during testing. 'service' is then queried for results (within @Then steps). Now that we need to handle two variations of MyService (http and JMS), can I configure JBehave to run thru the same stories twice, but injecting different versions of ServiceBuilder in to the StepsFile class for each iteration? Is there a better way to handle this kind of implementation variation? - 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 Actually, I think the 'Parametrized Stories' feature would work. This way I would not have to duplicate stories just because we support a new protocol. The documentation on it is unclear on how to leverage the parameter that is passed in to the story. Does someone know where I can find a working example of this feature? - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Re: [jbehave-user] jbehave with testng
Moved TestNG example to its own module trader-testng. On Thu Jan 5 17:34:36 2012, Graham Abell wrote: ignore this, found the details :) On 5 January 2012 16:08, Graham Abell wrote: Thanks Mauro, How do I pull the latest? On 5 January 2012 14:01, Mauro Talevi wrote: Pull latest trader example and you'll find a TestNGTraderStories class which you can run via TestNG. http://jira.codehaus.org/browse/JBEHAVE-698 On Thu Jan 5 14:27:05 2012, Graham Abell wrote: Thanks, I'd read that alright... I thought one of the samples might include it's usage but not to worry :) On 5 January 2012 13:21, Mauro Taleviwrote: You can easily support TestNG, as described here: http://jbehave.org/reference/stable/faq.html On Thu Jan 5 12:15:04 2012, Graham Abell wrote: Hi All, is there a working example of jbehave integrated with testng? thanks! graham - 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 - 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
Re: [jbehave-user] jbehave with testng
ignore this, found the details :) On 5 January 2012 16:08, Graham Abell wrote: > Thanks Mauro, > > How do I pull the latest? > > On 5 January 2012 14:01, Mauro Talevi wrote: >> Pull latest trader example and you'll find a TestNGTraderStories class which >> you can run via TestNG. >> >> http://jira.codehaus.org/browse/JBEHAVE-698 >> >> >> On Thu Jan 5 14:27:05 2012, Graham Abell wrote: >>> >>> Thanks, I'd read that alright... I thought one of the samples might >>> include it's usage but not to worry :) >>> >>> On 5 January 2012 13:21, Mauro Talevi wrote: You can easily support TestNG, as described here: http://jbehave.org/reference/stable/faq.html On Thu Jan 5 12:15:04 2012, Graham Abell wrote: > > > Hi All, > > is there a working example of jbehave integrated with testng? > > thanks! > graham > > - > 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 >> >> - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Re: [jbehave-user] jbehave with testng
Thanks Mauro, How do I pull the latest? On 5 January 2012 14:01, Mauro Talevi wrote: > Pull latest trader example and you'll find a TestNGTraderStories class which > you can run via TestNG. > > http://jira.codehaus.org/browse/JBEHAVE-698 > > > On Thu Jan 5 14:27:05 2012, Graham Abell wrote: >> >> Thanks, I'd read that alright... I thought one of the samples might >> include it's usage but not to worry :) >> >> On 5 January 2012 13:21, Mauro Talevi wrote: >>> >>> You can easily support TestNG, as described here: >>> http://jbehave.org/reference/stable/faq.html >>> >>> >>> On Thu Jan 5 12:15:04 2012, Graham Abell wrote: Hi All, is there a working example of jbehave integrated with testng? thanks! graham - 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 > > - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Re: [jbehave-user] jbehave with testng
Pull latest trader example and you'll find a TestNGTraderStories class which you can run via TestNG. http://jira.codehaus.org/browse/JBEHAVE-698 On Thu Jan 5 14:27:05 2012, Graham Abell wrote: Thanks, I'd read that alright... I thought one of the samples might include it's usage but not to worry :) On 5 January 2012 13:21, Mauro Talevi wrote: You can easily support TestNG, as described here: http://jbehave.org/reference/stable/faq.html On Thu Jan 5 12:15:04 2012, Graham Abell wrote: Hi All, is there a working example of jbehave integrated with testng? thanks! graham - 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
Re: [jbehave-user] jbehave with testng
Thanks, I'd read that alright... I thought one of the samples might include it's usage but not to worry :) On 5 January 2012 13:21, Mauro Talevi wrote: > You can easily support TestNG, as described here: > http://jbehave.org/reference/stable/faq.html > > > On Thu Jan 5 12:15:04 2012, Graham Abell wrote: >> >> Hi All, >> >> is there a working example of jbehave integrated with testng? >> >> thanks! >> graham >> >> - >> 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
Re: [jbehave-user] jbehave with testng
You can easily support TestNG, as described here: http://jbehave.org/reference/stable/faq.html On Thu Jan 5 12:15:04 2012, Graham Abell wrote: Hi All, is there a working example of jbehave integrated with testng? thanks! graham - 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
[jbehave-user] jbehave with testng
Hi All, is there a working example of jbehave integrated with testng? thanks! graham - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Re: [jbehave-user] Re: Can I reuse stories with two different implementations?
It may not be "business" functionality, but it is behaviour nonetheless. It may not concern all stakeholders, but there are surely some stakeholders (e.g. architecture, infrastructure) that would be interested in it. As such it needs to be expressed and verified. You could have one set of stories/scenarios that verify the business functionality with one default (non visible) protocol. Then have another set of stories that verify the same functionality for different protocols. On 05/01/2012 03:18, Sheldon wrote: Thanks Mauro. I was leaning towards that but it concerned me. It felt like the implementation was bleeding in to the stories. The customers rarely distinguish between transport protocols when discussing requirements, since it is mainly an engineering concern. So I felt uncomfortable including it in the stories. My hope was to run the requirements (i.e. stories) twice, one for http and JMS. Your suggestion is my fall back, though I am still wondering if there is an alternative solution. - To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email