Unable to Run Certain Unit Tests

已回答

I'm running into an issue where I try and run certain unit tests but get a failure as such below. Are there any solutions to fix this? I can run the test command line and attach a debugger but I think we should be able to run these within the IDE.

 

Command line is too long. Shorten command line for <fileName> or also for JUnit default configuration
9
正式评论

Hi!

If your command line is too long (OS is unable to create a process from command line of such length), IDEA provides you means to shorten the command line. The balloon should contain a link where you can switch between `none`|`classpath file`|`JAR-Manifest`|`args file (only available for jdk 9)`. If you run with any option but `none`, the command line would be shortened and OS should be able to start the process.

Do you still have a balloon when use one of the suggested (except `none`, please) options? If so, please enable debug option #com.intellij.execution.runners.ExecutionUtil (Help | Debug Log Settings), repeat running tests and attach idea.log (Help | Show log)

Thanks,

Anna

I have the very same issue in a completely different context. I am running a Spring Boot application. There is no other information, just the bubble with message:

`Error running 'XXXX': Command line is too long. Shorten command line for XXXX.`

And none of the four options helps.

1. user-local default: none --> no output, shows only the bubble

`Error running 'XXXX': Command line is too long. Shorten command line for XXXX.`

2. none -->  no output, shows only the bubble

`Error running 'XXXX': Command line is too long. Shorten command line for XXXX.`

3. JAR manifest --> output is

"C:\Program Files\Java\jdk1.8.0_162\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.1\lib\idea_rt.jar=50043:C:\Program Files\JetBrains\IntelliJ IDEA 2018.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\name\AppData\Local\Temp\classpath1723228166.jar packagename.ClassName
Exception in thread "main" java.io.FileNotFoundException: conf\server.properties (The system cannot find the path specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at java.io.FileReader.<init>(FileReader.java:58)
at packagename.ClassName.loadServerProperties(ClassName.java:23)
at packagename.ClassName(ClassName.java:18)
Process finished with exit code 1

4. classpath file --> output is

"C:\Program Files\Java\jdk1.8.0_162\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.1\lib\idea_rt.jar=50064:C:\Program Files\JetBrains\IntelliJ IDEA 2018.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2018.1\lib\idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\name\AppData\Local\Temp\idea_classpath packagename.ClassName
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:67)
Caused by: java.io.FileNotFoundException: conf\server.properties (The system cannot find the path specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at java.io.FileReader.<init>(FileReader.java:58)
at packagename.ClassName(ClassName.java:23)
at packagename.ClassName.main(ClassName.java:18)
... 5 more
Process finished with exit code 1
2
Avatar
Permanently deleted user

Hello Andrey,

 

I'm using 2017.3.4 and I am running it with a JUnit Run/Debug Configuration. I have tried all the dropdowns in the Shorten Command Line option (user-local default: none, none, JAR Manifest, and classpath file) and have not been able to run them. I have listed the errors I receive from the application when doing so.

 

user-local default: none

Command line is too long. Shorten command line for <fileName> or also for JUnit default configuration
none

Command line is too long. Shorten command line for <fileName> or also for JUnit default configuration
JAR Manifest

Test framework quit unexpectedly

C:\Java\jdk1.7.0_80_64bit\bin\java -Dvisualvm.id=137620844372576 -ea -Xms512m -Xmx1024m -XX:MaxPermSize=512m -javaagent:C:\Users\userName\.m2\repository/org/jmockit/jmockit/1.9/jmockit-1.9.jar @{argLine} -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.3\lib\idea_rt.jar=4803:C:\Program Files\JetBrains\IntelliJ IDEA 2017.3\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\userName\AppData\Local\Temp\classpath.jar com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.packagelevel2.packagelevel3.packagelevel4.packagelevel5.packagelevel6.FileNameTest
Error: Could not find or load main class @{argLine}

Process finished with exit code 1
classpath

Test framework quit unexpectedly

C:\Java\jdk1.7.0_80_64bit\bin\java -Dvisualvm.id=137834215187602 -ea -Xms512m -Xmx1024m -XX:MaxPermSize=512m -javaagent:C:\Users\userName\.m2\repository/org/jmockit/jmockit/1.9/jmockit-1.9.jar @{argLine} -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.3\lib\idea_rt.jar=4873:C:\Program Files\JetBrains\IntelliJ IDEA 2017.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2017.3\lib\idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\userName\AppData\Local\Temp\idea_classpath com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.packagelevel2.packagelevel3.packagelevel4.packagelevel5.packagelevel6.FileNameTest
Error: Could not find or load main class @{argLine}

Process finished with exit code 1

 

 

I have looked into the dynamic classpath flag and was able to change my workspace.xml file and with the settings below I got the same behavior.

<property name="dynamic.classpath" value="false" />

When changing the flag to true and restarting, the IDE changed the Run/Debug Configuration and still error-ed out:

<property name="dynamic.classpath" value="true" />
user-local default: JAR manifest
Test framework quit unexpectedly

C:\Java\jdk1.7.0_80_64bit\bin\java -Dvisualvm.id=137620844372576 -ea -Xms512m -Xmx1024m -XX:MaxPermSize=512m -javaagent:C:\Users\userName\.m2\repository/org/jmockit/jmockit/1.9/jmockit-1.9.jar @{argLine} -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.3\lib\idea_rt.jar=4803:C:\Program Files\JetBrains\IntelliJ IDEA 2017.3\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\userName\AppData\Local\Temp\classpath.jar com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.packagelevel2.packagelevel3.packagelevel4.packagelevel5.packagelevel6.FileNameTest
Error: Could not find or load main class @{argLine}

Process finished with exit code 1

 

Any other thoughts here?

1
Avatar
Permanently deleted user

I have hit the same fail for a junit test that loads a json file from the classpath. (windows 10, IJ 2017.3.4)

initially long classpath prevented test running, switching to classpath strategy allows test to run, but Test fails as can't find the test resource on classpath :(

Have downgraded to 2017.2 to evade problem.

suggestions?

1
Avatar
Permanently deleted user

Hello Andrey,

 

The original issue spawned from using the user-local default: none value for the shorten command line. The classpath file option behaves like the JAR Manifest from my observations.

 

There is no output, just a balloon popup with the message with the user-local default.

 

user-local default: none

Command line is too long. Shorten command line for <fileName> or also for JUnit default configuration

 

Sorry for the confusion

1

What is the IDE version you use? Do you run it with JUnit Run/Debug Configuration?

2017.3 version introduces configurable command line shortener when classpath is too long. Please see related blog post. Also you could try to change it manually in .idea/workspace.xml file, see What does the dynamic.classpath flag do.

0

Please post complete textual output from console Run(Debug) tool window when you launch the tests with the 'JAR manifest' option and 'classpath file' option where the full command line and the error would be seen.

Do you use any custom classloaders?

0

Alex, your problem seems different. Is in this thread we are discussing that Shorten command line option does not work and the same error is reported. In your case seems that the option helped for the initial issue but then test fails because of a different problem. Can you provide a sample test case? Or at least the full textual output you see when test fails fo you. How do you load the file in your code?

0
Avatar
Permanently deleted user

Andrey,

 

Are there any solutions to the issues I'm facing?

0

mykolGzy,

to find a solution we must understand the problem. Could you please kindly provide the information requested? Thanks.

0
Avatar
Permanently deleted user

Hello Andrey,

I updated https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000140604/comments/360000086164 with the information from the console. Also, I don't believe I am using any custom class loaders in these scenarios.

0

I see another error in the included console output: 

Error: Could not find or load main class @{argLine}

Which looks like the https://youtrack.jetbrains.com/issue/IDEA-143187 issue (see the workaround), and not the originally reported issue. Please clarify.

0
Avatar
Permanently deleted user

Hello Andrey,

 

I have tried the following (https://youtrack.jetbrains.com/issue/IDEA-143187#comment=27-1339297) :

Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Running Tests has a configuration option to skip passing argLine to the maven test runner.

 

This allows me to run the unit test within the IDE.

 

Also, you are correct. By using the workaround you suggested we exposed another issue (https://youtrack.jetbrains.com/issue/IDEA-143187), which also has a workaround stated above.

 

The original issue is that I get the following:

user-local default: none

Command line is too long. Shorten command line for <fileName> or also for JUnit default configuration

 

0

>The original issue is that I get the following:

We need full textual output from the Console tab when you are getting this error. Please post it here when you have the option Classpath file selected in Run Configuration. Thanks.

0
Avatar
Permanently deleted user

Hello Anna,

 

After making the change in Build, Execution, Deployment > Build Tools > Maven > Running Tests and uncheck the argLine, The tests will run, so I'm not running into issues there. Just in the case where none is being used where that flag is set.

0
Avatar
Permanently deleted user

Alex Fanshawe's solution of downgrading to 2017.2 worked great (I had just upgraded to 2018.1). I couldn't even find where the error was displayed. I just kept trying to run a test in 2018 and it wouldn't respond. No errors in the log, it just quietly did nothing.

I'm not really sure what the build command is. I have some corp plugin that mostly retrieves ~900+ packages from a corp server, and handles linking and such. Presumably, it may be affecting the situation.

On OSX 10.12.6 Sierra

 

 

0

What Run/Debug configuration type do you use? Please provide a screenshot of the configuration. What is the value of the Shorten command line option in this configuration?

0

@SergeBaranov: see my edited post. The problem started today.

I used to run this Spring Boot application without any problem still about a month ago. Today before launching I upgraded IDEA.

IntelliJ IDEA 2018.1.6 (Ultimate Edition)
Build #IU-181.5540.7, built on July 11, 2018
Licensed to MYNAME
Subscription is active until October 24, 2018
JRE: 1.8.0_152-release-1136-b39 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
0

Try 2018.2.1 version. Report a bug with the sample project attached at https://youtrack.jetbrains.com/issues/IDEA if the issue persists.

0

@SergeBaranov: I have tried the newest version as you had suggested. Still the same issue. However I am not permitted to upload the project, sorry. 

The screensharing session would be much faster as creating a dummy project. I do not know where the root cause is. And it is difficult to reduce the existing project, as other Spring Boot applications I have launch without the error.

 

0

Screen sharing will not help, try to create a dummy project to reproduce it or at least submit a report with the logs.

0

@SergeBaranov: The problem is most probably somewhere in our application. We upgraded a lot of libraries at the same time and probably some default folders changed. I will try to figure it out. It looks like the fault is not on the side of IntelliJ IDEA.

0

Hi, I'm running 2018.2.3, Windows 10 (probably latest, it complains and updates almost every day), Java 10 and encountering the same issue. My project is running gradle so not sure if the maven quick fix will work. I swear it was working yesterday, and today it stopped working. Maybe I need a restart or gradle clean or invalidate caches.

Maybe this is a throwback to the issue with Windows 10 not being able to run commands longer than X characters, aye.

Works on my Ubuntu VM.

0

This issue is about Win only. You need to choose command line shortening method from suggested list.

0

Hi Anna, thank you for the clarification. I'll try it out!

0
Avatar
Permanently deleted user

Faced with a similar problem. Solution found?

0

Hello Anna,

Have you tried "command line shortening" option?

 

0

Just updated to 2018.3.5 and have the same issue, on 2018.3.4 tests were run fine.
I set "shorten command line line" = "user-local default: none"

But it haven't helped.

Also I didn't get the solution from the discussion above. What is it?

0

Please report at https://youtrack.jetbrains.com/issues/IDEA and attach the full output from the run console and the error you get.

0
Avatar
Permanently deleted user

I'd also same issue, I set JRE to > "JRE Path in Program files" and Shorten Line command > "JAR manifest".

Then, it will work fine.

0

请先登录再写评论。