I need to pass String value (jbehave story file name) to .java file from cmd. Something like this:
mvn verify -PMyTests -DstoryName=purchasing.story
To use in java in that way:
System.out.println(storyName);
My setup:
Now tests being launched by
mvn verify -PMyTests
pom.xml file structure:
...
<dependencies>
...
</dependencies>
<build>
...
<build>
<profiles>
<profile>
<id>MyTests</id>
<build>
<plugins>
...
</plugins>
</build>
</profile>
MyStories.java:
public class MyStories extends JUnitStories {
...
@Override
protected List<String> storyPaths() {
return new StoryFinder()
.findPaths(codeLocationFromClass(embeddableClass).getFile(), asList(
"**/purchasing.story"
), null);
}
}
Tried these topics: Is there a way to use maven property in java class during compilation, How to pass java code a parameter from maven for testing, but with no result. Straightforward tutorials, search tips or documentation with examples appreciated.
P.S. Found solution which is simple enough and works for me: http://syntx.co/languages-frameworks/how-to-pass-parameters-to-the-junit-tests-from-the-maven-surefire-plugin/
Solution provided in comments (topic which I "duplicated") is more complex than this one so it is easier for novice to make mistake implementing it