Testing MiniJava in IntelliJ

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.

need to add -Djava.security.manager=allow to VM options

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,

  1. From the main menu, select Run | Edit Configurations
  2. Add -Djava.security.manager=allow to VM options.
    This will most likely be -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.

NoSuchFileException

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.

cannot find symbol class MiniJavaTestBuilder

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.