When running individual unit tests using the play button within IntelliJ, if the class name and method name or the combination thereof is longer than a certain limit, the test cannot be run and it throws "Command line is too long"
error. The fix here is to shorten the command line using classpath. We can also use jar manifest. For some reason that option wasn't working for me when I tried.
Under the run configuration for the test case, edit it and in the Build and Run
section, choose Modify options
. This will bring a menu from which select, Shorten command line
. This will add a new field to the build and run. In the Shorten command line
select menu, choose the classpath file
option. Save and exit the modal dialog and run the same test case again. This time it will work.
For first few tries these did not work. So I had edited the .idea/workspace.xml
to include the property <property name="dynamic.classpath" value="true" />
in the <component name="PropertiesComponent">
tag. Restarted and tried the above method and it worked. But I did find that this was removed automatically. So may be the above option alone is enough.