You might encounter several issues if you configured to run JUnit tests
through IntelliJ IDEA's run button instead of using
ant test
in either IntelliJ or in command line.
When using MiniJavaTestBuilder
, you might see the following
assertion failure:
java.lang.AssertionError: need to add -Djava.security.manager=allow to VM options.
To resolves this issue,
-Djava.security.manager=allow
to VM options. -ea
by default, so it should
now be -ea -Djava.security.manager=allow
.
Click OK and run the tests again, it should now work as expected.
Because IntelliJ IDEA runs the tests from the test
folder
instead of the project root like ant test
, file paths
specified in JUnit tests are likely only going to work for one of those.
We recommend using MiniJavaTestBuilder
so this is checked
and fixed automatically for you, or use CSE401TestingUtils
to implement manual resolution.
Make sure the utils
folder inside the test
folder is green, meaning a "Test Sources Root." If not,
right click on the utils
folder inside IntelliJ IDEA, select "Mark Directory As", and then
"Test Sources Root." See
IntelliJ IDEA | content roots for more info.