in ideaSupport/src/main/scala/org/jetbrains/sbtidea/tasks/IdeaConfigBuilder.scala [230:280]
private def generateModuleName(sourceSetModuleSuffix: String): String =
if (hasProdTestSeparationEnabled) s"$projectName.$sourceSetModuleSuffix"
else projectName
private def buildJUnitTemplate: String = {
val env = createEnvironmentVariablesSection(options.ideaTestEnv)
val vmOptionsStr = buildTestVmOptionsString
val argFilePath = runConfigDir / "junit_template_argfile.txt"
writeToFile(argFilePath, vmOptionsStr)
val vmOptionsStrArgfile = s"@${argFilePath.getAbsolutePath}"
val moduleName = generateModuleName(sourceSetModuleSuffix = "test")
val searchScope = if (options.testSearchScope.nonEmpty)
s"""<option name="TEST_SEARCH_SCOPE">
| <value defaultName="${options.testSearchScope}" />
| </option>""".stripMargin
else ""
// The VM_PARAMETERS option must contain a fake -cp option (with an empty string as a classpath),
// otherwise the platform will enforce the module classpath on our tests
// and completely disregard our classpath vm options.
// We then "override" this fake -cp argument with the -cp argument
// written to the argfile and we pass the whole argfile to java using the @argfile syntax.
s"""<component name="ProjectRunConfigurationManager">
| <configuration default="true" type="JUnit" factoryName="JUnit">
| <useClassPathOnly />
| $jreSettings
| <option name="MAIN_CLASS_NAME" value="" />
| <option name="METHOD_NAME" value="" />
| <option name="TEST_OBJECT" value="class" />
| <module name="$moduleName" />
| <option name="VM_PARAMETERS" value="-cp "" $vmOptionsStrArgfile" />
| <option name="WORKING_DIRECTORY" value="${options.workingDir}" />
| $searchScope
| <RunnerSettings RunnerId="Profile " />
| <RunnerSettings RunnerId="Run" />
| <ConfigurationWrapper RunnerId="Run" />
| $env
| <method v="2">
| <!-- We need to explicitly build the project, build artifact doesn't compile the tests -->
| <option name="Make" enabled="true" />
| <option name="BuildArtifacts" enabled="true">
| <artifact name="$artifactName" />
| </option>
| </method>
| </configuration>
|</component>""".stripMargin
}