Groovy Eclipse cannot run junit tests

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

Startup configuration input type does not exist

enter image description here

What input type is in the context of the startup configuration? (cannot find such an entry in the launch configuration window)

Note: I try sts 2.8.1 and e3.7

+11
source share
10 answers

This usually happens when the folder where the test case is located is not the source folder, check this post as well . Hope this helps!

+5
source

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

1) Make sure the class name exactly matches the file name (filename = MyTest.groovy )

 package com.mypackage; import groovy.util.GroovyTestCase; class MyTest extends GroovyTestCase {} 

2) Make sure that the package defined in the file matches the package in which the file is actually located.

+10
source

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

+2
source

In Eclipse you can do

 Right click -> properties -> Java build path 

Test folder notification is not available in sources. Add it.

 Add folder -> Select test -> OK 

Now restart the unit test cases.

enter image description here

+2
source

It also happened to me. But these tests are written in Groovy. The problem I am facing is how the IDE (Eclipse Kepler, Java EE) first opens the Groovy project after running "mvn eclipse: eclipse".

Build paths do not reference Groovy source files.

To decide I:

  • Right-click the project, choose Build Path> Configure Build Path ...
  • Select the Source tab
  • For test and src folders (... / src / main / groovy and ... / src / test / groovy)
  • make sure "** / *. groovy" is set to "Inclusion Patterns" and not "** / *. java"

Hope this saves time for someone.

Hooray!

+1
source

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

+1
source

I had a similar problem. As others have already indicated, it was a question of folders with sources. I had to change the setting of the source folder. An empty src folder appeared, which disappeared after I right-clicked it and selected "remove from build path" from the "Build path" menu. After that, I right-clicked both java / src and java / test folders and chose Build Path> Use As Source Folder. And suddenly my tests were JUnited!

In such situations, I would advise removing all the source folders from the build path and adding them again when you are sure that you have the correct ones. Your source folders should be those that have a Java package structure. In the case of proj / java / test / com / stackoverflow / main, this is the "test" folder.

0
source

This is what is allowed for me (Eclipse Oxygen) . I already did what Robert suggested in an earlier post. I was still getting the error. When I started editing the configuration to run junit, I saw that the Test Class field simply has a class name. I had to click the "Search" button on the right. The Test Class field now had a fully qualified name for the class.

 com.mycompany.mypackage.MyClass 

With this, I can run JUnit . But I must continue to correct this for each run.

0
source

2019 update: it drove me crazy for a few days, even with the latest versions of Eclipse and new installations (Mac, Grails 4, Gradle 5.1.1, Java 8). A few examples above led me to a solution.

My problem was that the code I tested included a mixture of groovy and java src / main code. He gave me NoClassDefFound for .groovy classes when I launched my Spec as JUnit.

Solution: I had to reconfigure Run / Debug to enable the / classes / groovy / main assembly. Then it worked. It’s a little pain to remember this for every new Configuration, but it makes me move on. I hope this helps you.

0
source

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

0
source

All Articles