Philippe Blayo
Philippe Blayo

Reputation: 11020

Groovy Eclipse can't launch junit tests

In Eclipse with groovy plugin, I try to launch a test @Test public void testToLaunch() {...} but I have the error:

The input type of the launch configuration does not exist

enter image description here

What input type is in the context of launch configuration? (can't find such an entry in launch configuration window)

Note: I try sts 2.8.1 and e3.7

Upvotes: 18

Views: 27107

Answers (13)

SeanDp32
SeanDp32

Reputation: 309

If you are using VS code Java Test Runner and "getting The input type of the Launch Configuration does not exist" ... Make sure your file and class name match. enter image description here

Upvotes: 0

df778899
df778899

Reputation: 10931

Found another way to cause this message. The cause turned out to be an empty copy of MyTest.java under src/main/java, as well as the real one under src/test/java.

Think the empty file was a hangover from some refactoring and was oddly causing no compile errors either. Deleting it enabled the test to run again.

Upvotes: 0

Thomas Rohde
Thomas Rohde

Reputation: 56

I had a spelling mistake which lead to that error message. My test class file name was named JUnit5Test.java (with upper U) and the class itself was named Junit5Test (with lower u).

I was using Spring Tool Suite 4 (4.8.0.RELEASE).

Upvotes: 2

Akshay Chopra
Akshay Chopra

Reputation: 1253

Whenever you create a Junit test in eclipse, make sure your Junit test file is inside src/test/java folder.

Upvotes: 1

kcostilow
kcostilow

Reputation: 146

2019 Update: This drove me crazy for days even with latest Eclipse and fresh installs (Mac, Grails 4, Gradle 5.1.1, Java 8). Some above examples led me to the solution.

My problem was more that the code I was testing included a mix of groovy and java src/main code. It gave me NoClassDefFound on the .groovy classes when I ran my Spec as JUnit.

Solution: I had to modify my Run/Debug Configuration to include build/classes/groovy/main. Then it worked. It's a little bit of a pain to remember to that for every new Configuration, but, it keeps me going. I hope it helps you.

Upvotes: 1

hindolam
hindolam

Reputation: 1

This is what resolved for me (Eclipse Oxygen). I had already done what Robert suggested in the earlier post. I was still getting the error. When I went to edit the configuration for junit launch, I saw that the Test Class field just had the class name. I had to hit the Search button to the right. The Test Class field now had the complete name for the class

com.mycompany.mypackage.MyClass

With this I am able to run the JUnit. But I have to keep fixing this for every run.

Upvotes: 0

user6408185
user6408185

Reputation:

I had a similar problem. Like others have already pointed out, it was about source folders. I had to change my source folder setup. There was an empty src-folder that disappeared after I right-clicked on it and selected 'remove from build path' from Build path menu. After that I right-clicked both java/src and java/test folders and chose Build path > Use as a source folder. And suddenly my tests were JUnited!

In similar situations I'd advice to remove all source folders from build path and add them again when you're sure you've got the right ones. Your source folders should be those with Java package structure under them. In case of proj/java/test/com/stackoverflow/main it's the 'test' folder.

Upvotes: 0

Aniket Thakur
Aniket Thakur

Reputation: 68935

In Eclipse you can do

Right click ->  properties -> Java build path

Notice test folder is not available in sources. Add it.

Add folder -> Select test -> OK

Now rerun you unit test cases.

enter image description here

Upvotes: 7

centic
centic

Reputation: 15872

I had the same error message when I head the test-class duplicated both in the main Java source folder and the testsrc folder. Removing the incorrectly placed one in the main Java source folder solved the problem for me.

Upvotes: 1

Aaron L. Johnson
Aaron L. Johnson

Reputation: 191

This can also happen if there is a problem with the groovy class. A few things to check:

1) Ensure that the class name exactly matches the filename (filename = MyTest.groovy)

package com.mypackage;
import groovy.util.GroovyTestCase;

class MyTest extends GroovyTestCase {}

2) Ensure that the package defined in the file matches the package the file is actually in.

Upvotes: 15

Robert
Robert

Reputation: 675

This also happened to me. But these tests are written in Groovy. The problem I encountered has to do with how the IDE (Eclipse Kepler, Java EE) first opens a Groovy project after executing "mvn eclipse:eclipse".

The Build Paths do not reference the Groovy source files correctly.

To resolve, I:

  1. Right-click on the project, select "Build Path" > "Configure Build Path..."
  2. Select "Source" tab
  3. For test and src folders (.../src/main/groovy, and .../src/test/groovy)
  4. make sure "**/*.groovy" is set as "Inclusion patterns", not "**/*.java"

Hope this saves time for someone.

Cheers!

Upvotes: 1

SGT Grumpy Pants
SGT Grumpy Pants

Reputation: 4436

This happened to me, and I just restarted Eclipse (GGTS) and everything was fine again.

Upvotes: 2

Anshu
Anshu

Reputation: 7853

This happens normally when the folder in which test case is present is not a source folder, please check this post as well. Hope that helps!

Upvotes: 12

Related Questions