This project demonstrates how to use MultiRTS together with JTeC.
To obtain the test traces necessary for selecting tests, we use JTeC. Note that we collect coverage at class level and collect all opened files.
$ mvn clean verify -Pjtec -Djtec.opts="test.trace,cov.trace,cov.instr,test.instr=false,sys.trace,sys.file,sys.socket=false,sys.thread=false,sys.process=false,test.reuseForks" jtec:report-aggregate
There are some sample changes in the patches directory. Simply apply them to test different scenarios.
$ git apply patches/01-simple-change.patch
$ git add .
$ git commit -m "01-simple-change"
$ mvn -Pmultirts multirts:module-selection -Dmultirts.sourceRevision="HEAD" -Dmultirts.targetRevision="HEAD~1" -Dmultirts.git=$(pwd)/..
$ cat target/.multirts/modules/modules.txt
foo/pom.xml
$ mvn -Pmultirts multirts:test-selection -Dmultirts.sourceRevision="HEAD" -Dmultirts.targetRevision="HEAD~1" -Dmultirts.git=$(pwd)/.. -Dmultirts.testReport=target/jtec/test-report.json
$ cat target/.multirts/tests/included.txt
a.b.c.foo.FooTest
a.b.c.bar.FooTestCase
$ cat target/.multirts/tests/modules.txt
bar/pom.xml
foo/pom.xml
Note that if you want to run the clean
goal, you need to store the artifacts generated by MultiRTS in another location than the default target/.multirts
.
$ mvn -Pmultirts install -DskipTests -Dmultirts.transitiveModules=target/.multirts/modules/modules.txt -Dmultirts.upstreamModules=target/.multirts/tests/modules.txt -Dmultirts.filterExecution=true
...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for parent 1.0-SNAPSHOT:
[INFO]
[INFO] parent ............................................. SUCCESS [ 0.002 s]
[INFO] foo ................................................ SUCCESS [ 0.641 s]
[INFO] bar ................................................ SUCCESS [ 0.022 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Note that it's important to specify an absolute path for the surefire.includesFile
option, as it will be called by each subproject in its respective working directory.
$ mvn -Pmultirts surefire:test -Dsurefire.includesFile=$(pwd)/target/.multirts/tests/included.txt -fn -Dmultirts.upstreamModules=target/.multirts/tests/modules.txt -Dmultirts.filterExecution=true
...
[ERROR] Failures:
[ERROR] FooTest.shouldFooReturnTrue:11 expected: <true> but was: <false>
...
[ERROR] Failures:
[ERROR] FooTestCase.shouldFooReturnTrue:11 expected: <true> but was: <false>