On 07/03/2016 13:53, Sander Mak wrote:
:
I was playing around with exactly this yesterday, and this is what I ended up
with:
javac -Xmodule:javamodularity.easytext.algorithm.naivesyllablecounter \
-XaddReads:javamodularity.easytext.algorithm.naivesyllablecounter=org.junit \
-mp mods:lib-test \
-d mods-test/javamodularity.easytext.algorithm.naivesyllablecounter
$(find src-test -name '*.java')
java -Xpatch:mods-test \
-XaddReads:javamodularity.easytext.algorithm.naivesyllablecounter=org.junit \
-XaddExports:javamodularity.easytext.algorithm.naivesyllablecounter/javamodularity.easytext.algorithm.naivesyllablecounter=org.junit
\
-mp mods:lib-test \
-addmods
javamodularity.easytext.algorithm.naivesyllablecounter,hamcrestcore \
-m org.junit/org.junit.runner.JUnitCore
javamodularity.easytext.algorithm.naivesyllablecounter.NaiveSyllableCounterTest
Which patches my application module to contain a unit test, and then exposes my
application module to junit at runtime (which is used as automatic module
here). This works as expected.
Good to see you got this working. Injecting tests into existing modules
and augmenting the module declaration so that the module reads the test
framework will be a bit advanced for many developers. I hope in time
that the IDEs and other tools will make this easy.
-Alan