Reputation: 167
I am getting ready for a small demo with karate and I have the following git project https://github.com/TheRasanjana/karateTesting. I'm building a Test suite with several features. I have mock-products.feature which I am invoking with my productRunner.java. As I am hoping to integrate this with jenkins in the future I want to execute all of them as a single test suite.
The tests Run successfully when I run each of the runner classes separately. I have a "AllTest.java" runner class outside the features to Run them all as a suite with command "mvn test -Dtest=AllTest". But in that case it won't invoke the mocks. Do I have to invoke the mocks inside AllTests.java as well?
What will be the right way of running all the features as a suite?
Upvotes: 3
Views: 2732
Reputation: 58128
The best way to run mocks in CI is a) use JUnit and b) include the JUnit classes in your test execution. So all you need to do is mvn test
and you can stop referring to any specific test-runner class.
Actually if you rename productsRunner
to ProductsTest
things are likely to start working the way you expect. If you add an @ignore
to products.feature
(so they are excluded from AllTest
and use @KarateOptions(features = "classpath:features/products/products.feature")
in ProductsTest
you are all set.
The Karate regression tests use the alternative approach where ProductsRunner
is explicitly added to the maven-surefire
section of the pom.xml
.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<includes>
<include>demo/DemoTestParallel.java</include>
<include>mock/contract/*Test.java</include>
<include>mock/micro/*Runner.java</include>
<include>mock/proxy/*Runner.java</include>
<include>ssl/*Test.java</include>
</includes>
</configuration>
</plugin>
See the example and read the documentation: https://github.com/intuit/karate#command-line
Upvotes: 1