Monday, August 12, 2013

IntelliJ Idea, JUnit running, and "non Make" build steps.

IntelliJ Idea provides some really awesome JUnit runners that allow you to right click test methods, classes, and packages, and quickly run/debug them.

The default JUnit configuration runs Idea's "Make" prior to running your test. This however becomes incredibly painful when you have separate build steps, such as generated sources (protobuf), bytecode manipulation (jibx), etc.  Although you are able to change default settings for the JUnit runner, these default settings are stored in the project workspace file, which shouldn't be checked into source control when working with other teams.

IntelliJ will detect default run configurations placed in the ipr, however, it will immediately remove it and place it in the workspace file... again, another conflict for source control.

This is where the Gradle idea plugin can come in.  Since all of the custom build steps should come in after running the "testClasses" target (pending your are running a Java project... it's up to you to figure out other project types), one can add a Run configuration to run testClasses, and then make the default JUnit configuration depend on that run configuration.

No comments:

Post a Comment