Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to use GivenStories having Examples table in story files #12

Closed
jopombar opened this issue May 24, 2012 · 6 comments
Closed

Not able to use GivenStories having Examples table in story files #12

jopombar opened this issue May 24, 2012 · 6 comments
Labels
Milestone

Comments

@jopombar
Copy link

To reproduce:

  • Have a story that uses GivenStories referring to a story that has an Examples table

Notice that the execution stops just after printing the example to be executed
By experimenting I also found out the following:

  • The execution succeeds if a story with not GivenStories is run before the one with GivenStories
  • Even when it executes correctly in the above scenario there is no check mark in the JUnit view for the steps in the story with the GivenStories

Here is the stack trace I see

17:47:11.406 [pool-2-thread-1] INFO  d.c.j.j.m.JUnitScenarioReporter - Example: {emailAddress=USER, password=PASSWORD, SecCodePageTitle=enterCode.title, OTP=TEMP.PASSCODE, HomePageTitle=home.title}
17:47:11.609 [main] INFO  d.c.j.j.m.JUnitScenarioReporter - Before Story: AfterStories 

(AfterStories)
17:47:11.609 [main] INFO  d.c.j.j.m.JUnitScenarioReporter - After Story: AfterStories(java.lang.Object) 

Generating reports view to 'C:\workspace_noSpace\maven.1337379448984\trunk\target\jbehave' using formats '[stats, selenium_context, console, html, junitscenarioreporter]' and view properties '{defaultFormats=stats, decorateNonHtml=true, viewDirectory=view, decorated=ftl/jbehave-report-decorated.ftl, reports=ftl/jbehave-reports-with-totals.ftl, maps=ftl/jbehave-maps.ftl, navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl}'
Reports view generated with 2 stories (of which 0 pending) containing 4 scenarios (of which 0 pending)
java.lang.RuntimeException: org.jbehave.core.embedder.Embedder$RunningStoriesFailed: Failures in running stories: 
vipmgr_switchOrg.story: org.jbehave.core.embedder.StoryManager$StoryExecutionFailed: vipmgr_switchOrg.story
    at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.run(JUnitReportingRunner.java:116)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.jbehave.core.embedder.Embedder$RunningStoriesFailed: Failures in running stories: 
vipmgr_switchOrg.story: org.jbehave.core.embedder.StoryManager$StoryExecutionFailed: vipmgr_switchOrg.story
    at org.jbehave.core.embedder.Embedder$ThrowingRunningStoriesFailed.handleFailures(Embedder.java:515)
    at org.jbehave.core.embedder.Embedder.handleFailures(Embedder.java:244)
    at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:226)
    at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.run(JUnitReportingRunner.java:114)
    ... 6 more
@ghost ghost assigned AndreasEK May 24, 2012
@AndreasEK
Copy link
Contributor

Okay, this probably won't work yet. Another complication in the logic for the scenarioReporter :) Thanks for reporting this!

Just out of curiosity: what's your use-case for combining given stories and examples tables?

@jopombar
Copy link
Author

Hi Andreas,
Thank you for working on such a great tool. I went ahead and cleaned up my flow, there was no need to have examples tables in the GivenStories only on the story using the GivenStories. Here how to reproduce now:

  • Have a story that uses GivenStories that is parameterized with an example table
  • Have the GivenStory also parameterized with the values coming from the example table from the parent story

This flow works just fine with jBehave-Web but it throws the exception above when using JUnitReportingRunner. My use case is the following:

  • I'm testing a webApp
  • I'm testing a feature of the webApp for example generateReports functionality. I can select different type of reports (this is where I use the parent's parameterization)
  • To do anything in the webApp the user needs to login first. Here is where I call GivenStories: baseLogin.story
  • We have different types of users in the webApp (admin, regular, etc). This is where I need GivenStory parameterization, to provide the user type in the parent story

@dschneller
Copy link
Contributor

Intriguing. Could you post the relevant sections of your story files? I haven't used parameterized GivenStories yet, would like to see what you have done. Also, it would give is a test case :)

@AndreasEK
Copy link
Contributor

At the same time I noticed, that the test suite AfterStories is not green anymore. Somewhere the test case counting went haywire. Opening new bug for that.

@jopombar
Copy link
Author

@daniel, take a look at "given_stories_parametrised_by_examples.story" on the jbehave-trader-example (jbehave-core/examples/trader). This story has the structure I'm taking about. There are other good GivenStories examples there as well. Let me know if you still want me to post my stories

@andreas,
The fix works and my stories run. Thanks a lot! :-)
If I want to be picky I do have the following to report:

  • Multi level GivenStories don't show on the JUnit window. Only the first GivenStory shows but if this GivenStory has a GivenStory that one doesn't show
  • The steps of the GivenStory don't show. There is only 1 line with the story name and it doesn't have a check mark even though it ran successfully.

I would consider these "enhancements" since the feature now works. This might be related Issue #16 you opened. Let me know if you want me to add that detail there or open a new issue

@AndreasEK
Copy link
Contributor

Hi,

glad that this is fixed for you :)

About your pickiness. You are absolutely right. I knew about the second point, but haven't even thought about nesting Given Stories :) The technical background is, that while we're building the test execution tree for JUnit prior to executing it, we only get the given story as a path, so we would have to somehow parse it. I don't know yet how to do that with JBehave. Maybe it's not that difficult. So please, if you don't mind, create two enhancements.

Thanks and enjoy your weekend. Hope you have such a great weather as we in Germany do.

Andreas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants