Can you please provide either a self contained maven-based sample
project to reproduce this behaviour?
Either a zip or a github repo.
Thanks
On 14/03/2016 15:57, Mrunal Gosar wrote:
I am using JBehave for writing BDD Integration tests.
Problem: JBehave clears state of objects (instance variables) while
executing individual steps
Code: StepDefinition:
|publicclassStepDefs{privateStringstr;@Given("step represents a
precondition to an
$event")publicvoidgiven(Stringevent){str=event;System.out.println("Given:
"+str);}@When("step represents the occurrence of the
event")publicvoidwhen(){System.out.println("When: "+str);}@Then("step
represents the outcome of the event")publicvoidthen(){}}|
Story:
|Samplestory Narrative:Inorder to communicate effectively to the
business some functionality Asa development team I want to use
Behaviour-DrivenDevelopmentScenario:A scenario is a collection of
executable steps of different type Givenstep represents a precondition
to an event Whenstep represents the occurrence of the event Thenstep
represents the outcome of the event|
JBehaveJUnitTestRunner:
|@RunWith(JUnitReportingRunner.class)publicclassJBehaveTestsRunnerextendsJUnitStories{privateCrossReferencexref
=newCrossReference();publicJBehaveTestsRunner(){configuredEmbedder().embedderControls().doGenerateViewAfterStories(true).doIgnoreFailureInStories(true).doIgnoreFailureInView(true).doVerboseFailures(true);//
.useThreads(1);}@OverridepublicConfigurationconfiguration(){PropertiesviewResources
=newProperties();viewResources.put("decorateNonHtml","true");returnnewMostUsefulConfiguration().useStoryLoader(newLoadFromClasspath(this.getClass().getClassLoader())).useStoryReporterBuilder(newStoryReporterBuilder().withFormats(Format.HTML,Format.CONSOLE,Format.STATS).withViewResources(viewResources).withFailureTrace(true).withFailureTraceCompression(false).withCrossReference(xref));}@OverridepublicInjectableStepsFactorystepsFactory(){returnnewScanningStepsFactory(configuration(),"stepdefs");}@OverridepublicList<String>storyPaths(){StoryFinderfinder
=newStoryFinder();returnfinder.findPaths(CodeLocations.codeLocationFromClass(getClass()),Arrays.asList("**/Simple.story"),null);}}|
Actual Output:
|Processingsystem properties {}Usingcontrols
EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=true,ignoreFailureInView=true,verboseFailures=true,verboseFiltering=false,storyTimeouts=300,threads=1,failOnStoryTimeout=false](BeforeStories)Runningstory
stories/Simple.story Samplestory
(stories/Simple.story)Narrative:Inorder to communicate effectively to
the business some functionality Asa development team I want to use
Behaviour-DrivenDevelopmentScenario:A scenario is a collection of
executable steps of different type **Given:event**Givenstep represents
a precondition to an event **When:null**Whenstep represents the
occurrence of the event Thenstep represents the outcome of the event
(AfterStories)Generatingreports view to
'C:\WORKING\lunaworkspace\pkeautomation\target\jbehave'using formats
'[html, console, stats, junitscenarioreporter]'and view properties
'{decorateNonHtml=true}'log4j:WARN Noappenders could be found
forlogger (freemarker.cache).log4j:WARN Pleaseinitialize the log4j
system properly.Reportsview generated with 3stories (of which
1pending)containing 2scenarios (of which 1pending)|
As can be seen in the output: In the Given step I am accepting a
string argument which i am initializing it to instance variable "str",
whilst printing the value to console I can see it successfully. But
when the second step i.e When step executes I am getting null as the
value of instance variable "str". How can I make JBehave to not clear
state of objects after executing individual steps?
--
You received this message because you are subscribed to the Google
Groups "JBehave User" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web, visit
https://groups.google.com/d/msgid/jbehave-user/d5ed5293-59fe-40aa-93f0-7cd4c5fc2f88%40googlegroups.com
<https://groups.google.com/d/msgid/jbehave-user/d5ed5293-59fe-40aa-93f0-7cd4c5fc2f88%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "JBehave
User" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send an email to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msgid/jbehave-user/56E897E6.4030102%40aquilonia.org.
For more options, visit https://groups.google.com/d/optout.