Platform inconsistency when running tests with TestNG


I’m working on a project with Gradle and tests in this project are managed with TestNG and I’ve run into a strange scenario.

My goal is to be able to execute specific tests by filtering them with test groups. I have my test task configured this way:

    useTestNG() {
      System.getProperty("testGroups")?.let {

and I trigger the tests running: ./gradlew clean test -DtestGroups=unitTests

This works as expected when I try to run the tests on my local machine - a mac, but when I try to run the tests on a CI server, Jenkins in this case, it appears that the testGroup specification is ignored and all the tests are executed.

I’ve spent quite some time trying to figure out what could be causing this, thanks in advance for your help!