valfirst / jbehave-junit-runner Goto Github PK
View Code? Open in Web Editor NEWIntegrate JBehave better with JUnit. Reports all Stories, Scenarios and Steps as JUnit Suites and Test Cases.
License: MIT License
Integrate JBehave better with JUnit. Reports all Stories, Scenarios and Steps as JUnit Suites and Test Cases.
License: MIT License
To reproduce:
Have a class extending JUnitStories with the following configuration:
@RunWith(JUnitReportingRunner.class)
public class AwesomeNameStories extends JUnitStories {
public AwesomeNameStories() {
CrossReference crossReference = new CrossReference().withJsonOnly().withOutputAfterEachStory(true)
.excludingStoriesWithNoExecutedScenarios(true);
ContextView contextView = new LocalFrameContextView().sized(640, 120);
SeleniumContext seleniumContext = new SeleniumContext();
SeleniumStepMonitor stepMonitor = new SeleniumStepMonitor(contextView, seleniumContext,
crossReference.getStepMonitor());
Format[] formats = new Format[] { new SeleniumContextOutput(seleniumContext), CONSOLE, WEB_DRIVER_HTML };
StoryReporterBuilder reporterBuilder = new StoryReporterBuilder()
.withCodeLocation(codeLocationFromClass(AwesomeNameStories.class)).withFailureTrace(true)
.withFailureTraceCompression(true).withDefaultFormats().withFormats(formats)
.withCrossReference(crossReference);
Configuration configuration = new SeleniumConfiguration().useSeleniumContext(seleniumContext)
.useFailureStrategy(new FailingUponPendingStep())
.useStoryControls(new StoryControls().doResetStateBeforeScenario(false)).useStepMonitor(stepMonitor)
.useStoryLoader(new LoadFromClasspath(AwesomeNameStories.class))
.useStoryReporterBuilder(reporterBuilder);
useConfiguration(configuration);
ApplicationContext context = new SpringApplicationContextFactory("vipmgr-steps.xml").createApplicationContext();
useStepsFactory(new SpringStepsFactory(configuration, context));
}
When you run you'll get the following stack trace:
java.lang.NullPointerException: story not setup for CrossReference
at org.jbehave.core.reporters.CrossReference$XRefStepMonitor.stepMatchesPattern(CrossReference.java:228)
at org.jbehave.core.steps.DelegatingStepMonitor.stepMatchesPattern(DelegatingStepMonitor.java:25)
at org.jbehave.core.steps.StepCandidate.matches(StepCandidate.java:135)
at de.codecentric.jbehave.junit.monitoring.JUnitDescriptionGenerator.addSteps(JUnitDescriptionGenerator.java:97)
at de.codecentric.jbehave.junit.monitoring.JUnitDescriptionGenerator.addScenarioSteps(JUnitDescriptionGenerator.java:90)
at de.codecentric.jbehave.junit.monitoring.JUnitDescriptionGenerator.insertDescriptionForExamples(JUnitDescriptionGenerator.java:84)
at de.codecentric.jbehave.junit.monitoring.JUnitDescriptionGenerator.createDescriptionFrom(JUnitDescriptionGenerator.java:50)
at de.codecentric.jbehave.junit.monitoring.JUnitDescriptionGenerator.createDescriptionFrom(JUnitDescriptionGenerator.java:38)
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.buildDescriptionFromStories(JUnitReportingRunner.java:100)
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.<init>(JUnitReportingRunner.java:57)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
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)
Seems like when calling CrossReference.stepMatchesPattern(), the call to
Story story = currentStory.get();
Returns a null story, so maybe currentStory was never initialized
Currently, when setting up the JUnitReportingRunner, the configured storyReporter is discarded. Instead the own JUnitScenarioReporter is used in order to receive notifications from JBehave.
This probably also causes #8.
We had quite a few requests on how to use the jbehave-junit-runner together with spring. The problem is, that both, our library and spring test provide a JUnitRunner and only one runner can be declared per test.
We should document a way to inject members into a jbehave junit test using spring. The easiest way would probably be, to create an ApplicationContext
in the @Before
hock by hand, get an AutowireCapableFactoryBean
from there and then call autowireBean(Object)
passing in the this reference (see also: http://stackoverflow.com/questions/3813588/how-to-inject-dependencies-into-a-self-instantiated-object-in-spring).
I have a bunch of stories that I am trying to run using:
@RunWith(JUnitReportingRunner.class)
public class AllStories extends JUnitStories
{
...
}
In my pom.xml I have:
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>jbehave-junit-runner</artifactId>
<version>1.1.0</version>
</dependency>
The screenshot shows a step that has failed yet the scenario shows as passed. What could be causing this?
Hello,
I am using Netbeans which is delegating test runs to Maven/Surefire directly, so in the end it boils down to a call as mentioned in the title.
mvn clean test -Dtest=MyStories
Now I am getting:
-------------------------------------------------------------------------------
Test set: de.friedenhagen.jbehavesimple.MyStories
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.338 sec <<< FAILURE!
de.friedenhagen.jbehavesimple.MyStories Time elapsed: 0 sec <<< ERROR!
java.lang.NullPointerException
at de.codecentric.jbehave.junit.monitoring.JUnitScenarioReporter.<init>(JUnitScenarioReporter.java:55)
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.run(JUnitReportingRunner.java:80)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
You may easily reproduce this by cloning git://github.com/mfriedenhagen/jbehave-simple.git and running mvn clean test -Dtest=MyStories
.
Travis CI is a nice and easy way to get a project into a CI environment. Since it is for free, we should activate it for this project. This may require getting in touch with the owner of the codecentric github account. Docs on Travis CI can be found here.
Don't stage manually, but automate the staging process as described:
Automate:
http://www.sonatype.com/books/nexus-book/reference/staging-sect-managing-plugin.html
shouldGenerateDescriptionWithoutCrossReference()
in JUnitReportingRunnerTest
contains a TODO
comment stating: "no idea how this should be tested!". This test method should either be fixed (preferred) or removed.
When I override candidateSteps() Method (I know it is @deprecated) in my Test Class instead of stepsFactory(), I see no progress in JUnit Tab.
To reproduce this issue remove in ExampleScenarioJUnitStories stepsFactory() and write this:
@Override
public List<CandidateSteps> candidateSteps() {
return new InstanceStepsFactory(configuration(), new ExampleSteps()).createCandidateSteps();
}
JUnitReportingRunner is overwritign all pre-configured reporters (for formats like XML, HTML and others).
Insted, JUnitReportingRunner could just add the JUnitScenarioReporter to the list of reporters configured by the existing StoryReporterBuilder, if any.
Junit doesnt display full details of scenarios/steps executed.
11 scenarios are reported although only 2 are actually defined.
Using intellijJ 13.1.2
Source project: https://www.dropbox.com/s/yg4tldm90xbgs5s/jbeh1.rar
I was able to reproduce on two machines. I create the projects using Maven Archetypes, so maybe there is the issue.
We shouldn't force dependencies on our clients, that are not absolutely necessary. For example we have the dependency to mockito defined in scope compile, although we're only using it in our test code.
Configuring JBehave to fail on pending steps causes a RuntimeException in 1.0.1.
@RunWith(JUnitReportingRunner.class)
public class Foobar extends JUnitStory {
@Override
public Configuration configuration() {
return super.configuration().usePendingStepStrategy(new FailingUponPendingStep());
}
}
java.lang.RuntimeException: org.jbehave.core.embedder.Embedder$RunningStoriesFailed: Failures in running stories:
foo/foobar.story: org.jbehave.core.embedder.StoryManager$StoryExecutionFailed: foo/foobar.story
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.run(JUnitReportingRunner.java:81)
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:
foo/foobar.story: org.jbehave.core.embedder.StoryManager$StoryExecutionFailed: foo/foobar.story
at org.jbehave.core.embedder.Embedder$ThrowingRunningStoriesFailed.handleFailures(Embedder.java:495)
at org.jbehave.core.embedder.Embedder.handleFailures(Embedder.java:224)
at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:205)
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.run(JUnitReportingRunner.java:79)
... 6 more
Description is here:
https://docs.sonatype.org/display/repository/sonatype+oss+maven+repository+usage+guide#SonatypeOSSMavenRepositoryUsageGuide-6.CentralSyncRequirement
Ticket for hosting is already created:
https://issues.sonatype.org/browse/OSSRH-3514
Hi everyone,
I just wanted to let you know that I find something a bit odd (perhaps considerable as a bug?) when using jbehave-junit-runner 1.0.1.
If any story file doesn't contain an initial description before the first scenario definition, the test fails during initialization with the following stacktrace:
Processing system properties {}
Using controls EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=false,ignoreFailureInView=false,verboseFailures=false,verboseFiltering=false,storyTimeoutInSecs=300,threads=1]
Generating reports view to '/home/user/project/target/jbehave' using formats '[stats, console, txt, 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 16 scenarios (of which 0 pending)
java.lang.RuntimeException: java.lang.NullPointerException
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.run(JUnitReportingRunner.java:81)
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: java.lang.NullPointerException
at de.codecentric.jbehave.junit.monitoring.JUnitScenarioReporter.beforeStory(JUnitScenarioReporter.java:84)
at org.jbehave.core.reporters.DelegatingStoryReporter.beforeStory(DelegatingStoryReporter.java:67)
at org.jbehave.core.reporters.ConcurrentStoryReporter.beforeStory(ConcurrentStoryReporter.java:107)
at org.jbehave.core.embedder.StoryRunner.runBeforeOrAfterStories(StoryRunner.java:70)
at org.jbehave.core.embedder.StoryManager.runBeforeOrAfterStories(StoryManager.java:91)
at org.jbehave.core.embedder.StoryManager.runStories(StoryManager.java:75)
at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:202)
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.run(JUnitReportingRunner.java:79)
... 6 more
Looking up at JUnitScenarioReporter.java:84 I've found out that a description is necessary.
I would propose a fix myself but since I don't have currently the time to run through the whole code, I'm just signaling it :)
Btw, it looks like the problem doesn't appear if you are running a JUnitStory instead of JUnitStories, but I don't have time now to reproduce the thing.
Thanks!
“After/Before Stories” is always listed although not present, but for Story or Scenario they are not listed, even when present.
I guess this stems from the problem not to know which steps class has (or hasn’t) such methods and which one of them failed.
HI there,
I tried to use your jbehave-junit-runner into my project but I got a java.lang.NullPointerException.
I just added it to my pom.xml and I included @RunWith(JUnitReportingRunner.class) in MyStories class, which extends to JUnitStories.
The failure trace is this one:
java.lang.NullPointerException
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.(JUnitReportingRunner.java:59)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.junit.internal.requests.SortingRequest.getRunner(SortingRequest.java:21)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
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)
If you need my code/class, let me know and I will send to you.
Thanks in advance
Firstly, thank you for your very useful library! It helps me a lot for working with Spring, JBehave and JUnit.
I got an issue when I tried to use Spring @transactional annotation (to rollback transaction automatically): by using 'SpringJUnitReportingRunner', everything worked well but transaction didn't rollback. Then, I changed to use 'SpringJUnit4ClassRunner', run test again. After test done, I could saw transaction rollback as I expected, but very poor result in JUnit view :(. I was wonder if maybe Spring @transactional annotation was ignored by classes: SpringJUnitReportingRunner/ JUnitReportingRunner?
JBehave 3.6.7 supports Given-Stories at Story-Level:
http://jira.codehaus.org/browse/JBEHAVE-792
The SpringReportingJUnitRunner hasn't been well thought out in the first place. We shouldn't push something like this out. Beside that, it looks like Spring will provide a test rule soon, making it possible to use the jbehave-junit-runner in conjunction with DI.
Right now the reporting only works, when JBehave is executing the tests in a single thread. It'd be nice, to allow JBehave to run tests multithreaded - with working reporting to JUnit.
Implementation idea: put all state in the reporter (currentScenario, etc) in a ThreadLocal context. This should be achieved fairly easily and should work under the assumption that one scenario / story is completely executed in one Thread.
I am currently using a guice annotated path runner, which means that the @RunWith annotation is already used, is there a way to somehow chain this together or would it be necessary to write a guice reporting runner?
I tried this with v1.0.1.
Version : 1.0.1
Problem:
When a step fails jbehave report seem to add '\u200B' at the end of the line in the error report, please see the example as below. Is it because of de.codecentric.jbehave.junit.monitoring.DescriptionTextUniquefier.getUniqueDescription.
com.test.steps.TrainingTest.When I perform a Java training\u200B
com.test.steps.TrainingTest.When I perform a Java training\u200B\u200B
com.test.steps.TrainingTest.When I perform a Java training\u200B\u200B\u200B
com.test.steps.TrainingTest.When I perform a Java training\u200B\u200B\u200B\u200B
com.test.steps.TrainingTest.When I perform a Java training\u200B\u200B\u200B\u200B\u200B
com.test.steps.TrainingTest.When I perform a Java training\u200B\u200B\u200B\u200B\u200B\u200B
com.test.steps.TrainingTest.When I perform a Java training\u200B\u200B\u200B\u200B\u200B\u200B\u200B
com.test.steps.TrainingTest.When I perform a Java training\u200B\u200B\u200B\u200B\u200B\u200B\u200B\u200B
com.test.steps.TrainingTest.When I perform a Java training\u200B\u200B\u200B\u200B\u200B\u200B\u200B\u200B\u200B
Can you please let me know if I am doing anything wrong?. I am using Single threaded tests.
Thanks
Girish
For some stories we have a carriage return (\r) in a step.
JBehave itself doesn't have any problems with it, but the junit-runner stops showing the junit descriptions
Scenario: using and steps
Given a variable x with value 3
And a variable x with value 3
When I multiply x by 3
And I multiply x by 5
Then x should equal 50
Both steps "And ..." don't show up in JUnit.
We should not reinvent the will. Let's use something like slf4j for logging and deprecate the Logger class, making it ready for removal in the next major release.
JUnit doesn't receive the notification any longer, that all tests are finished. When running, the notifications cause a higher testcount than originally estimated when creating the test desriptions.
Hi
We really benefit from using your jar to provide us with clearer debugs and runs through eclipse. However we have just upgraded from JBehave-core-3.8 to 3.9 (released mid dec 2013) and found that we cannot use version 1.0.2 with this.
Please could you update jbehave-junit-runner to support jbehave-core-3.9 and junit-4.11?
many thanks
We've forgotten to remove prepareConfigurableEmbedder in 1.1.1. So wie should remove it now.
Another issue for the troubleshooting section.
JBehave Steps that make use Selenium WebDriver will fail because jbehave-junit-runner will cause the test to instantiate a WebDriver before it is required.
One workaround is to create a WebDriver Proxy/Wrapper that will delay the instantiation of the target Selenium WebDriver until it is really necessary.
For example:
public class WebDriverProxy implements WebDriver, JavascriptExecutor {
@SuppressWarnings("rawtypes")
private final Class webDriverClass;
private WebDriver driver;
@SuppressWarnings("rawtypes")
public WebDriverProxy(final Class webDriverClass) {
this.webDriverClass = webDriverClass;
}
public WebDriver getDriver() {
if (this.driver == null) {
try {
this.driver = (WebDriver) this.webDriverClass.newInstance();
}
catch (final InstantiationException e) {
e.printStackTrace();
}
catch (final IllegalAccessException e) {
e.printStackTrace();
}
}
return this.driver;
}
@PreDestroy
public void clean() {
quit();
}
public void get(final String url) {
getDriver().get(url);
}
public String getCurrentUrl() {
return getDriver().getCurrentUrl();
}
public String getTitle() {
return getDriver().getTitle();
}
public List<WebElement> findElements(final By by) {
return getDriver().findElements(by);
}
public WebElement findElement(final By by) {
return getDriver().findElement(by);
}
public String getPageSource() {
return getDriver().getPageSource();
}
public void close() {
getDriver().close();
}
public void quit() {
getDriver().quit();
}
public Set<String> getWindowHandles() {
return getDriver().getWindowHandles();
}
public String getWindowHandle() {
return getDriver().getWindowHandle();
}
public TargetLocator switchTo() {
return getDriver().switchTo();
}
public Navigation navigate() {
return getDriver().navigate();
}
public Options manage() {
return getDriver().manage();
}
public Object executeScript(final String script, final Object... args) {
return ((JavascriptExecutor) getDriver()).executeScript(script, args);
}
public Object executeAsyncScript(final String script, final Object... args) {
return ((JavascriptExecutor) getDriver()).executeAsyncScript(script, args);
}
}
and configure it in Spring:
<bean id="webDriver" class="com.foo.WebDriverProxy">
<constructor-arg value="org.openqa.selenium.firefox.FirefoxDriver"/>
</bean>
then use it in your JBehave Steps:
@Component("fooSteps")
public class FooSteps {
@Autowired
private WebDriver driver;
...
}
You can have composite steps in JBehave. They are not yet supported and confuse JUnit.
If a new scenario is added with missing steps (no binding code exists), the steps are not added to the report tree and even worse, the scenario is marked OK.
Personally I’d want those to be reported as failures (with a stub implementation text extractable from the failure trace) – but I can imagine others might not want this behaviour; Is there a possibility to add configuration options to the JUnitReportingRunner?
The missing steps should at least be reported like pending steps.
This is just a small note for the troubleshooting section:
An older test was working just fine with the now deprecated JUnitStories.candidateSteps().
jbehave-junit-runner will not execute if this is being used. Instead, one should make sure JUnitStories.stepsFactory() is being used/overridden.
Great work!
The JUnitReportingRunner instantiates step classes before any scenarios are actually executed as a part of an attempt to build JUnit Descriptions. This can create a problem with Guice integrations (and possibly others).
When Guice is configured to instantiate Step classes as singletons, it doesn't make any difference. But when using Guice custom scopes--for example, scoping a Step to a scenario--this causes the runner to fail, because objects required by the Step don't exist until a scenario exists. The exact error with stack trace is included below.
The problem code is inside JUnitDescriptionGenerator.addRegularStep(), as shown below:
Description testDescription = Description.createTestDescription(step
.getStepsInstance().getClass(), getJunitSafeString(stringStep));
description.addChild(testDescription);
The Description requires the Class only, not an instance of the Class. Is there a way to obtain the Class of the Step without requiring an instance? That would fix this problem. A quick glance at the JBehave StepCandidate class suggest that the Class type is not exposed, but perhaps there is some other way to get it.
A link to a sample project exposing the problem is here: http://bit.ly/11pLRvq (sorry, it's the only way I could find to upload it--GitHub doesn't allow file attachments). Note: you must run it through Eclipse to see the problem. Maven does not see the test class. This problem is specific to the JUnitReportingRunner. Running with the default AnnotatedEmbedderRunner works normally.
Version information is in the pom.xml, and also included below:
jbehave-junit-runner: 1.0.1
jbehave: 3.6.9
Error:
com.google.inject.ProvisionException: Guice provision errors:
1 error
at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:987)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1009)
at org.jbehave.core.steps.guice.GuiceStepsFactory.addInstances(GuiceStepsFactory.java:72)
at org.jbehave.core.steps.guice.GuiceStepsFactory.createInstanceOfType(GuiceStepsFactory.java:61)
at org.jbehave.core.steps.StepCandidate.getStepsInstance(StepCandidate.java:68)
at de.codecentric.jbehave.junit.monitoring.JUnitDescriptionGenerator.addRegularStep(JUnitDescriptionGenerator.java:190)
at de.codecentric.jbehave.junit.monitoring.JUnitDescriptionGenerator.addExistingStep(JUnitDescriptionGenerator.java:148)
at de.codecentric.jbehave.junit.monitoring.JUnitDescriptionGenerator.addSteps(JUnitDescriptionGenerator.java:138)
at de.codecentric.jbehave.junit.monitoring.JUnitDescriptionGenerator.addStepsToExample(JUnitDescriptionGenerator.java:127)
at de.codecentric.jbehave.junit.monitoring.JUnitDescriptionGenerator.createDescriptionFrom(JUnitDescriptionGenerator.java:57)
at de.codecentric.jbehave.junit.monitoring.JUnitDescriptionGenerator.addAllScenariosToDescription(JUnitDescriptionGenerator.java:208)
at de.codecentric.jbehave.junit.monitoring.JUnitDescriptionGenerator.createDescriptionFrom(JUnitDescriptionGenerator.java:44)
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.addStories(JUnitReportingRunner.java:194)
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.buildDescriptionFromStories(JUnitReportingRunner.java:181)
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.(JUnitReportingRunner.java:51)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
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: com.google.inject.OutOfScopeException: Cannot access Key[type=example.ScenarioScopeSteps, annotation=[none]] outside of a scoping block
at example.SimpleScope.getScopedObjectMap(SimpleScope.java:97)
at example.SimpleScope.access$0(SimpleScope.java:94)
at example.SimpleScope$2.get(SimpleScope.java:81)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)
... 32 more
As of now I can't seem to get version 1.0.1 from central (http://repo1.maven.org/maven2/de/codecentric/jbehave-junit-runner/). If the search function of central is used, version 1.0.1 can be found but only in the "Releases" repo. Any ideas?
Hello, I have just started to use this project. On eclipse junit it works great. However when I try a Gradle build it fails because it can't write the xml test results.
I'm running on WIndows 7 64bits
Java version Java SE 1.6.0_45
Jbehave 3.8
The test case with all the information I think you need can be found at
https://github.com/jucoba/JavaWebTestUtils
Just run gradle build inside JavaWebTestUtilsProject
If you need any extra information please tell me
Thank you
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':CalculadoraApp:test'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.changedetection.state.CacheLockReleasingTaskExecuter$1.run(CacheLockReleasingTaskExecuter.java:35)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:179)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:232)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:142)
at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:83)
at org.gradle.api.internal.changedetection.state.CacheLockReleasingTaskExecuter.execute(CacheLockReleasingTaskExecuter.java:33)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.ContextualisingTaskExecuter.execute(ContextualisingTaskExecuter.java:34)
at org.gradle.api.internal.changedetection.state.CacheLockAcquiringTaskExecuter$1.run(CacheLockAcquiringTaskExecuter.java:39)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:124)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:112)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:134)
at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)
at org.gradle.api.internal.changedetection.state.CacheLockAcquiringTaskExecuter.execute(CacheLockAcquiringTaskExecuter.java:37)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:282)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.executeTask(DefaultTaskPlanExecutor.java:48)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.processTask(DefaultTaskPlanExecutor.java:34)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:27)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:89)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
at org.gradle.api.internal.changedetection.state.TaskCacheLockHandlingBuildExecuter$1.run(TaskCacheLockHandlingBuildExecuter.java:31)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:124)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:112)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:134)
at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)
at org.gradle.api.internal.changedetection.state.TaskCacheLockHandlingBuildExecuter.execute(TaskCacheLockHandlingBuildExecuter.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:48)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.Main.main(Main.java:39)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
Caused by: org.gradle.api.GradleException: Could not write XML test results for Scenario: Ingreso a calculadora sin usuario to file D:\sura_desarrollo\JavaWeb
tils\JavaWebTestUtilsProject\CalculadoraApp\build\test-results\TEST-Scenario: Ingreso a calculadora sin usuario.xml.
at org.gradle.api.internal.tasks.testing.junit.result.Binary2JUnitXmlReportGenerator$1.execute(Binary2JUnitXmlReportGenerator.java:57)
at org.gradle.api.internal.tasks.testing.junit.result.Binary2JUnitXmlReportGenerator$1.execute(Binary2JUnitXmlReportGenerator.java:48)
at org.gradle.api.internal.tasks.testing.junit.result.TestReportDataCollector.visitClasses(TestReportDataCollector.java:95)
at org.gradle.api.internal.tasks.testing.junit.result.Binary2JUnitXmlReportGenerator.generate(Binary2JUnitXmlReportGenerator.java:48)
at org.gradle.api.tasks.testing.Test.executeTests(Test.java:455)
at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
at org.gradle.api.tasks.testing.Test_Decorated.invokeMethod(Unknown Source)
at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:217)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:199)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:526)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:509)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 67 more
Caused by: java.lang.NullPointerException
at org.gradle.api.internal.xml.SimpleMarkupWriter.writeXmlAttributeEncoded(SimpleMarkupWriter.java:372)
at org.gradle.api.internal.xml.SimpleMarkupWriter.attribute(SimpleMarkupWriter.java:241)
at org.gradle.api.internal.tasks.testing.junit.result.JUnitXmlResultWriter.writeTests(JUnitXmlResultWriter.java:83)
at org.gradle.api.internal.tasks.testing.junit.result.JUnitXmlResultWriter.write(JUnitXmlResultWriter.java:60)
at org.gradle.api.internal.tasks.testing.junit.result.Binary2JUnitXmlReportGenerator$1.execute(Binary2JUnitXmlReportGenerator.java:54)
... 83 more
The README.markdown has become pretty overloaded with all sorts of information. It may make sense to create a github page that we can use documentation.
Currently we have several example stories in the src/test folder. While mvn test will ignore these tests and give you immediate feedback if everything is okay, running all tests in eclipse/intellij will show a red bar. This is because some of the example stories are only there to fail. This is confusing and we should create a new example project that only contains the example stories. The src/test folder in the main project should only contain real tests for the library.
In my current project there is an older slf4j-API version in use. Although backwards compatible, it is a hassle to reconfigure builds and settings to use the newer API just to satisfy the JUnit runner. As there usually is no need for any users of the runner to see its internal logging output, I recommend an (even simpler ;-)) approach to logging for internal use.
In relation to #5, the count of run/found tests is wrong when a story contains missing steps:
When a scenario contains only missing steps, nothing is counted to the total, but an additional run is counted.
Given a story with only one scenario consisting of missing steps
When the story is run in JUnit
Then 3/2 runs are reported
Considering missing steps are to be reported:
Then 5/5 runs should be reported
(The 2 extra runs are for the Before/After Stories steps)
This might be a side-effect of an empty tree entry for test descriptions, automatically solved when #5 is solved.
When using the single-story embedder a switch could be done to JUnitStories with not much effort - but it would be great if the runner is capable of handling this case on its own.
At a client today, a step failed when webdriver couldn't locate a certain element. The step was red in the JUnit view in eclipse, but no helpful details available.
We already have some kind of release notes, since we're documenting fixed issues via milestones. However, it makes sense to provide users with an overview of what has changed between releases.
Configure the maven-changes plugin to generate release notes.
Hi - I am using GherkinStoryParser using jbehave. When I use JUnitReportingRunner, only BeforeStories and AfterStories are run and the .feature file is not getting executed. Here is the code and error. Please help. What could be the issue? Any help is much appreciated.
@RunWith(JUnitReportingRunner.class)
public class CalcConfig extends JUnitStories {
public CalcConfig() {
super();
JUnitReportingRunner.recommandedControls(configuredEmbedder());
}
@OverRide
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
return new MostUsefulConfiguration()
.useStoryParser(new GherkinStoryParser())
.useStoryLoader(new LoadFromClasspath(embeddableClass))
.useStoryReporterBuilder(
new StoryReporterBuilder().withDefaultFormats()
.withFormats(STATS, HTML, TXT, CONSOLE))
.useParameterControls(
new ParameterControls()
.useDelimiterNamedParameters(true));
}
@OverRide
public InjectableStepsFactory stepsFactory() {
return new InstanceStepsFactory(configuration(), new CalcSteps());
}
@OverRide
protected List storyPaths() {
return new StoryFinder().findPaths(
codeLocationFromClass(this.getClass()), "*/.feature", "");
}
}
============================ Here is the error I am getting:
Failed to run story test/resources/calculator/Calculator.feature java.lang.AbstractMethodError: de.codecentric.jbehave.junit.monitoring.JUnitScenarioReporter.lifecyle(Lorg/jbehave/core/model/Lifecycle;)V at org.jbehave.core.reporters.DelegatingStoryReporter.lifecyle(DelegatingStoryReporter.java:79) at org.jbehave.core.reporters.ConcurrentStoryReporter.lifecyle(ConcurrentStoryReporter.java:137) at org.jbehave.core.embedder.StoryRunner.runCancellable(StoryRunner.java:277) at org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:220) at org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:181) at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:229) at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:201) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:680)
(AfterStories)
Generating reports view to '/Documents/workspace/Calculator/jbehave' using formats '[stats, stats, html, txt, console, 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 0 stories (of which 0 pending) containing 0 scenarios (of which 0 pending)
The Scenario reporter so far only copes with failures in steps. Exceptions while executing annotated methods (@BeforeStories, ...) reporter to JUnit with a false notification.
I have this pom.xml:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<configuration>
<skipTests>true</skipTests>
</configuration>
</execution>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
<failIfNoTests>true</failIfNoTests>
<includes>
<include>**/tests/**/Math*Tests.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
When executing it's telling me:
[INFO] --- maven-surefire-plugin:2.10:test (integration-test) @ functional.tests ---
[INFO] Surefire report directory: D:\repos\git\ops\functional-tests\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.onassignment.ops.tests.MathStoriesTests
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.485 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
I was expecting some number, and a nice JUnit compatible report.
When a step in a scenario looks like this
Given something with a few params:
| Header |
| Value |
everthing works fine.
But when the step is commented out like this:
!-- Given something with a few params:
| Header |
| Value |
JBehave executes the steps before and after that, however not progress is reported at all for any steps in any story in the IDE JUnit view.
Version: 1.0.2-SNAPSHOT as of 2012-05-31 17:45 ( commit 19c1b18 )
To reproduce:
Notice that the execution stops just after printing the example to be executed
By experimenting I also found out the following:
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
Can I use jbehave-junit-runner with Spring Test? I use @RunWith annotation for Spring Test and I can't use it for JUnitReportingRunner. My code:
@ActiveProfiles("test-h2")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext/test-applicationContext.xml"})
public abstract class AbstractConfigurationTest extends JUnitStories {
@Override
public Configuration configuration() {
return new MostUsefulConfiguration().useStoryLoader(new LoadFromClasspath(this.getClass()))
.useStoryReporterBuilder(new StoryReporterBuilder().withFormats(Format.CONSOLE).withFailureTrace(true));
}
}
Although the tab character is the default indentation character in eclipse, it is not very well suited for distributed development. The display of the tab character depends on the clients OS and editor. For this reason it's common to use spaces for indentation. We should follow this commons practice.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.