Simple project based on the JBehave tutorial available at github You can use this example project to build your own JBehave-based testing solution.
- src/main/java/tech/test/Stories.java is the entry-point that JBehave uses to run the stories.
- src/main/stories contains the stories run by JBehave via Stories.java.
- src/main/java/tech/test/steps/Steps.java contains the steps mapped to the textual steps.
- src/main/java/tech/test/pages contains the Java page-objects used by steps to abstract in a more manageable and maintainable way the interaction with the web pages via Selenium WebDriver.
- src/main/resources/techtest-steps.xml contains the Spring configuration for composition the steps
- JDK 6+
- Maven 2+
- Firefox 10+
Once all the required tools are installed:
-
create two new system variables:
- JAVA_HOME e.g.: JAVA_HOME=C:\Program Files\Java\jdk1.7.0_10
- M2_HOME e.g.: M2_HOME=C:\Program Files\apache-maven-3.0.5
-
add paths to the firefox, java and maven folders containing corresponding binaries to the Path variable, e.g.:
Path=WHATEVER_WAS_THERE_BEFORE;C:\Program Files\Java\jdk1.7.0_10\bin;C:\Program Files\apache-maven-3.0.5\bin;C:\Program Files (x86)\Mozilla Firefox\
NOTES:
- More information on [FirefoxDriver] 1
- Handy tutorial on setting $PATH and environmental variables in Windows.
- FF binary (firefox.exe) can usually be found in %PROGRAMFILES%\Mozilla Firefox
Is similar to Windows one. Simply make sure that:
- JAVA_HOME and M2_HOME system variables are properly set.
- folder with Firefox binary is in your $PATH system variable
NOTES:
- More information on [FirefoxDriver] 1
- Handy tutorial on setting $PATH and environmental variables under *nix systems.
- Another one just on setting up the java path variable.
- FF binary can be found using "which" command.
Same thing as with Windows and Linux You need to make sure that:
- JAVA_HOME and M2_HOME are set accordingly
- folder with Firefox binary is in your $PATH system variable
NOTES:
-
More information on [FirefoxDriver] 1
-
Here's a nice tutorial on setting $PATH and environmental variables in Mac.
-
Usually FF binary (filename is firefox-bin) is placed in:
/Applications/Firefox.app/Contents/MacOS/
Create a new text file with '.story' extension in the src/main/stories folder. Then write down the body of the user story you want to run.
IntelliJ Idea 12
- Right-click on the Stories class, select "Run 'Stories'"
Eclipse EE Juno SR2 with M2E plugin v1.3.0
- Right-click on the Stories class, select "Run as" -> "JUnit Test"
Go to the 'RunSingleStory.java' method 'runTest' and change the name of the user story you want to run. Remember that the story name has to be exactly the same as the story filename but without the '.story' extension.
After that in:
IntelliJ Idea 12
- Right-click on the RunSingleStory class, select "Run 'RunSingleStory'"
Eclipse EE Juno SR2 with M2E plugin v1.3.0
- Right-click on the RunSingleStory class, select "Run as" -> "JUnit Test"
This will run the build and (after a minute or so) Firefox will open and run your tests against the yell.com website:
mvn clean install
This will run a single story (one contained in a searchFromHomePage.story file):
mvn clean install -DstoryFilter=searchFromHomePage
This will run a suite based on the meta filters in the three story files:
mvn clean install -Dmeta.filter="+page home"
After each run new report can be found in target/jbehave/view. Report file is named: 'reports.html' There should be a row for each story. The story reports are clickable to via links on the right-most column.