I have the following project structure:
MyProject
--src
--test
--acceptance
--step_definitions
--features
--unit
I would like to be able to run my cucumber tests (in test/acceptance) separately in Maven from the unit tests declared in test/unit, so that they can be run in different CI build plans etc. I am using cucumber-junit so the 'runners' for each acceptance test are written with JUnit.
Is this possible?
The other answer suggested modifying your folder structure to have shared folder for integration and acceptance tests, but you can have the original folder structure as well. Also you mentioned in the comment you want to keep all three (including not-mentioned integration tests) separate, which is possible, though hackish.
Since you seem to have
test/unit
for unit tests andtest/acceptance
for acceptance test, I'm assumingtest/integration
for integration tests.Note though that separation only applies for sources: compiled files will all go to the same folder, and AFAIK that's something you can't change. This means you need to have naming strategy for your tests to separate them from each other.
Yes, it is possible. I believe you should separate your unit from the acceptance/integration tests having:
Slightly modified folders structure for both of these, placing your integration test files in the standard location of
src/it
:MyProject/
src/main/java/
(SUT)src/test/
(unit test code)java/
resources/
src/it/
(acceptance/integration tests)java/
(steps definitions)resources/
(feature files)Moreover, by design, different Maven plugins are intended for unit and integration tests:
maven-surefire-plugin
maven-failsafe-plugin
You must also bind execution of
maven-failsafe-pulgin
. To run the integration tests separately, you can define a new profile:You will also need to configure the plugin to search the
src/it
directory tree for test cases.The acceptance tests can be run afterwards using:
For complete sample, I'd suggest you to follow http://www.weblogism.com/item/334/integration-tests-with-cucumber-jvm-selenium-and-maven