It is possible to take a Maven/JUnit-based test suite that takes too long to run on a single node and parallelize the test execution across multiple nodes instead.
The Parallel Test Executor Plugin is exactly for that purpose.
Jenkinsfile
1234567891011121314151617181920
node('remote'){git'https://github.com/jenkinsci/parallel-test-executor-plugin-sample.git'stashname:'sources',includes:'pom.xml,src/'}defsplits=splitTestscount(2)defbranches=[:]for(inti=0;i<splits.size();i++){defindex=i// fresh variable per iteration; i will be mutatedbranches["split${i}"]={node('remote'){deleteDir()unstash'sources'defexclusions=splits.get(index);writeFilefile:'exclusions.txt',text:exclusions.join("\n")sh"${tool 'M3'}/bin/mvn -B -Dmaven.test.failure.ignore test"junit'target/surefire-reports/*.xml'}}}parallelbranches
Note that, this is different from modiyfing test harness (e.g., JUnit, TestNG) to parallelize the test execution on a single node.
It could be time-consuming and risk destabalizing the tests while the chance of success is usually small.