Comments (13)
Yes, please provide the test class you are using that exhibits this problem. I have an idea, but would like to verify.
from jbehave-junit-runner.
Here you are my class. I hope there is my problem :)
package org.jbehave.business;
import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.jbehave.business.generic.GenericConfiguration;
import org.jbehave.business.generic.GenericFormat;
import org.jbehave.business.generic.GenericStep;
import org.jbehave.business.utils.PropertyConstants;
import org.jbehave.business.utils.StringUtil;
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.embedder.Embedder;
import org.jbehave.core.io.LoadFromRelativeFile;
import org.jbehave.core.io.StoryFinder;
import org.jbehave.core.junit.JUnitStories;
import org.jbehave.core.model.ExamplesTableFactory;
import org.jbehave.core.parsers.RegexStoryParser;
import org.jbehave.core.reporters.CrossReference;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.CandidateSteps;
import org.jbehave.core.steps.InstanceStepsFactory;
import org.jbehave.core.steps.spring.SpringApplicationContextFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.ApplicationContext;
import de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner;
@RunWith(JUnitReportingRunner.class)
public class MyStories extends JUnitStories {
private static Configuration configuration = null;
private static GenericConfiguration coreConfiguration = null;
private static CrossReference xref = null;
@SuppressWarnings("rawtypes")
private static List steps = null;
@SuppressWarnings({"rawtypes", "unchecked" })
public MyStories() {
try {
xref = new CrossReference().withJsonOnly().withOutputAfterEachStory(true).excludingStoriesWithNoExecutedScenarios(true);
//ApplicationContext appContext = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
String path = "org.jbehave.business".replaceAll("\\.", "/");
ApplicationContext appContext = new SpringApplicationContextFactory(path + "/applicationContext.xml").createApplicationContext();
coreConfiguration = appContext.getBean("config", GenericConfiguration.class);
Map beanMap = appContext.getBeansOfType(GenericStep.class);
steps = new ArrayList(beanMap.values());
Embedder processor = new Embedder();
processor.embedderControls().doGenerateViewAfterStories(true);
processor.embedderControls().doIgnoreFailureInStories(true);
useEmbedder(processor);
} catch (Throwable e) {
e.printStackTrace();
}
}
/**
* set the configuration of JBehave.
*
* @return Configuration for JBehave
*/
@Override
public Configuration configuration() {
if (configuration == null) {
StoryReporterBuilder reporterBuilder = new StoryReporterBuilder();
// Selected output format
reporterBuilder.withFormats(GenericFormat.getFormatArray(coreConfiguration.getStringArray(PropertyConstants.REPORT_FORMAT)));
reporterBuilder.withFailureTrace(true);
reporterBuilder.withFailureTraceCompression(false);
reporterBuilder.withCrossReference(xref);
configuration = new MostUsefulConfiguration();
File codeLocation = new File(coreConfiguration.getString(PropertyConstants.STORY_PATH));
try {
configuration.useStoryLoader(new LoadFromRelativeFile(codeLocation.toURI().toURL()));
configuration.useStoryParser(new RegexStoryParser(new ExamplesTableFactory(new LoadFromRelativeFile(codeLocation.toURI().toURL()))));
} catch (MalformedURLException e) {
e.printStackTrace();
}
configuration.useStoryReporterBuilder(reporterBuilder);
configuration.useStepMonitor(xref.getStepMonitor());
}
return configuration;
}
@SuppressWarnings("unchecked")
@Override
public List<CandidateSteps> candidateSteps() {
InstanceStepsFactory stepFactory = new InstanceStepsFactory(configuration(), steps);
return stepFactory.createCandidateSteps();
}
/**
* load the story files from a path.
*
* @return a list of paths for stories
*/
@Override
protected List<String> storyPaths() {
String separator = StringUtil.defaultIfEmpty(coreConfiguration.getString(PropertyConstants.STORY_SEPARATOR), ",");
List<String> includes = StringUtil.toList(coreConfiguration.getString(PropertyConstants.STORY_INLCUDE), separator);
List<String> excludes = StringUtil.toList(coreConfiguration.getString(PropertyConstants.STORY_EXLUDE), separator);
List<String> storyPaths = new StoryFinder().findPaths(coreConfiguration.getString(PropertyConstants.STORY_PATH), includes, excludes);
return storyPaths;
}
@Override
@Test
public void run() {
try {
super.run();
} catch (Throwable th) {
th.printStackTrace();
}
}
}
from jbehave-junit-runner.
Hi,
which version of the jbehave-junit-runner are you using? If you are using 1.0.0 please try out the 1.0.1-SNAPSHOT as there's a bugfix contained for using CrossReferences (Issue #8)
Andreas
from jbehave-junit-runner.
That's what I wanted to check :)
from jbehave-junit-runner.
Hi guys,
I downloaded the last SNAPSHOT (jbehave-junit-runner-1.0.1-20120525.215233-12) and I even commented the code of the CrossReferences but the problems is still there. I realised that the following line is failing in the JUnitReportingRunner: candidateSteps = embedder.stepsFactory().createCandidateSteps();
It seems that the embedder.stepsFactory() get a NULL.
from jbehave-junit-runner.
Hi Manuel,
thanks for the debugging. I'll try to reproduce the problem with your information.
Andreas
from jbehave-junit-runner.
Hi,
back from further evaluation :) It seems to me, that you're only extending JUnitStories half-way. You've chosen to override candidateSteps(), but not stepsFactory(). Also you've your own implementation of the run method. May I ask, why you chose to implement your class like this?
That said, I've changed the implementation to use the stepsFactory from the Embedder, which has a fallback to a ProvidedStepsFactory, if none was given. Hope that fixes the issue for you :)
from jbehave-junit-runner.
Hi, can you please check again with the latest SNAPSHOT? Thanks, Andreas
from jbehave-junit-runner.
Thanks @AndreasEK, I will check if the latest SNAPSHOT solves the issue. In addition, "answering" your question...
It seems to me, that you're only extending JUnitStories half-way. You've chosen to override candidateSteps(), but not stepsFactory(). Also you've your own implementation of the run method. May I ask, why you chose to implement your class like this?
I home working with this class right now but it is not developed by me, so I do not have any asnwer. Annyway, I would appreciate if you give me some advice on it, so please write me via email, [email protected], or just share it with all of us over here.
from jbehave-junit-runner.
Thank you again, @AndreasEK. It works perfectly. Great job ;)
from jbehave-junit-runner.
great. I see a release of version 1.0.1 coming. Feedback on your class either here or on our blog (generalized).
from jbehave-junit-runner.
Cool. Let me know where the feedback is ready. Is it your blog? http://blog.codecentric.de/en/
from jbehave-junit-runner.
Yep, that's our blog. FYI: I just released 1.0.1 :) Have fun, Andreas
from jbehave-junit-runner.
Related Issues (20)
- Move to JUnit 5
- Suggestion on using this with WeldAnnotatedEmbedderRunner
- Handle RestartingScenarioFailure HOT 1
- Filtering out all scenarios in the story file causes NPE HOT 9
- How to make Junit runner read limited words from scenario and create .xml file from it. HOT 4
- I cannot start single scenario in eclipse HOT 5
- NPE on Failure.getTestHeader(Failure.java:44) when step throws assert in Lifecycle>After>FAILURE
- Using JUnitReportingRunner with pitest HOT 2
- Export the report in any other format
- Tests failing on master HOT 2
- How to generate the jbehave-surefire.xml file with parametrised examples HOT 5
- JUnitScenarioReporter throws NPE when story file name contains parentheses HOT 3
- Throws RuntimeException on scenario failure instead of java.lang.AssertionError HOT 2
- jbehave-junit-runner by maven and not from IDE HOT 7
- Jbehave-junit-runner incorrectly shows scenarios being executed when mata keywords applied in Jbehave 4 version HOT 13
- bad checksum on repo1.maven.org HOT 1
- Not showing correct test names in IntelliJ HOT 7
- Customize output monitor HOT 1
- Comments in scenario are reported as ignored HOT 10
- Remove fix for special IntelliJ handling
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jbehave-junit-runner.