Comments (6)
Hi people, this is other example :)
package com.miuler.service.features;
import static java.util.Arrays.asList;
import static org.jbehave.core.io.CodeLocations.codeLocationFromClass;
import java.util.List;
import org.jbehave.core.annotations.Configure;
import org.jbehave.core.annotations.UsingEmbedder;
import org.jbehave.core.annotations.UsingSteps;
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.io.LoadFromClasspath;
import org.jbehave.core.io.StoryFinder;
import org.jbehave.core.junit.JUnitStories;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.ScanningStepsFactory;
import org.jbehave.core.steps.spring.SpringApplicationContextFactory;
import org.jbehave.core.steps.spring.SpringStepsFactory;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestContextManager;
import de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner;
@RunWith(JUnitReportingRunner.class)
@ContextConfiguration(locations = {
// DAO
"/com/miuler/dao/config/spring-config.xml",
// Service
"/com/miuler/service/config/spring-service.xml"
})
public class RunFeaturesTest extends JUnitStories {
@Autowired
ApplicationContext applicationContext;
private TestContextManager testContextManager;
public RunFeatures867Test() {
JUnitReportingRunner.recommendedControls(configuredEmbedder());
}
@Override
protected List<String> storyPaths() {
String searchInDirectory = codeLocationFromClass(getClass()).getFile();
return new StoryFinder().findPaths(searchInDirectory, asList("**/*.story"), null);
}
@Override
public Configuration configuration() {
try {
this.testContextManager = new TestContextManager(getClass());
this.testContextManager.prepareTestInstance(this);
} catch (Exception e) {
throw new RuntimeException(e);
}
return new MostUsefulConfiguration()
.useStoryLoader(new LoadFromClasspath(this.getClass()))
.useStoryReporterBuilder(new StoryReporterBuilder().withFormats(Format.CONSOLE, Format.HTML))
;
}
@Override
public InjectableStepsFactory stepsFactory() {
return new SpringStepsFactory(configuration(), applicationContext);
}
}
from jbehave-junit-runner.
You can only use one test runner per test, so it's not possible to annotate your test with both test runners. Googling "junit use multiple runners" gave me this result: http://www.blog.project13.pl/index.php/coding/1077/runwith-junit4-with-both-springjunit4classrunner-and-parameterized/
Maybe this is what you're looking for?
from jbehave-junit-runner.
Based on link in comment I found a solution:
@ActiveProfiles("test-h2")
@RunWith(JUnitReportingRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext/test-applicationContext.xml"})
public abstract class AbstractConfigurationTest extends JUnitStories {
private TestContextManager testContextManager;
public AbstractConfigurationTest() {
JUnitReportingRunner.recommandedControls(configuredEmbedder());
}
@Override
public Configuration configuration() {
this.testContextManager = new TestContextManager(getClass());
try {
this.testContextManager.prepareTestInstance(this);
} catch (final Exception e) {
throw new RuntimeException(e);
}
return new MostUsefulConfiguration().useStoryLoader(new LoadFromClasspath(this.getClass()))
.useStoryReporterBuilder(new StoryReporterBuilder().withFormats(Format.CONSOLE));
}
}
from jbehave-junit-runner.
Nice that you figured that one out. Thanks for the example, it may help others looking for the same thing.
from jbehave-junit-runner.
I am confused about @RunWith(SpringJUnitReportingRunner.class) removal from jbehave-junit-runner jar.
README file in git;
https://github.com/schmidtl/jbehave-junit-runner
still contain the example below:
@RunWith(SpringJUnitReportingRunner.class)
@ContextConfiguration(locations = "classpath:spring-test.xml")
public class MyAcceptanceTests extends JUnitStories {
@Autowired
private WebDriverSteps lifecycleSteps;
...
}
from jbehave-junit-runner.
mstachniuk - Thank you uring for figuring this out! Kudos! One more thing should be done in order to enable autowiring in steps classes is override:
@OverRide
public InjectableStepsFactory stepsFactory() {
ApplicationContext context = new SpringApplicationContextFactory("/properties/mps-steps.xml").createApplicationContext();
return new SpringStepsFactory(configuration(), context);
}
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
- Inconsistent versions HOT 10
- 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.