Run Karate tests for Bugfest

Run Karate tests for Bugfest

We can run a specific set of Karate tests designed for Bugfest by filtering Java classes by their name, to either include or exclude a select number classes that we want to be picked up by Maven Surefire.

There are 3 types of Karate test groups that we intent to use with this approach:

  • Smoke

  • Extended

  • Critical Path

As a prerequisite for this to work, we define our Karate test features as normal but store their Java methods exclusively in their dedicated Java classes, for example OrdersSmokeApiTest.java contains only Java methods created for smoke testing.

Including Test Groups

To run a particular test group include -Dtest flag in your Maven test command, for example:

mvn clean test -pl common,common-consortia,testrail-integration,acquisitions \ -Dkarate.env=dev -Dsurefire.failIfNoSpecifiedTests=false \ -Dtest=**/*Smoke*

This will allow Maven to selectively compile and run only Java classes stored within the acquisitions submodule with Smoke pattern anywhere in their file name.

We can also run multiple groups by passing more patterns into the flag and delimit them with commas.

mvn clean test -pl common,common-consortia,testrail-integration,acquisitions \ -Dkarate.env=dev -Dsurefire.failIfNoSpecifiedTests=false \ -Dtest=**/*Smoke*,**/*Extended*

Excluding Test Groups

To exclude any of the test groups from our the nightly Karate CI runs, we can modify Maven test command with -Dsurefire.excludes flag.

Here we exclude all Bugfest test groups and run Karate as normal:

mvn clean test -pl common,common-consortia,testrail-integration,acquisitions \ -Dkarate.env=dev -Dsurefire.failIfNoSpecifiedTests=false \ -Dsurefire.excludes=**/*Smoke*.java,**/*Extended*.java,**/*CriticalPath*.java

 

Sources: