'No JUnit tests found' in Eclipse

后端 未结 22 2742
闹比i
闹比i 2020-12-13 08:35

So I\'m new to JUnit, and we have to use it for a homework assignment. Our professor gave us a project that has one test class, BallTest.java. When I right clic

相关标签:
22条回答
  • 2020-12-13 08:57

    Try this

    Right Click on the Unit Test Class,

    1. Select "Run As" -> Run Configuration
    2. In the "Test" tab, make sure in the field "Test runner" select drop down "JUnit 4"
    3. Click "Apply"

    Now Run the test!

    0 讨论(0)
  • 2020-12-13 08:57

    Came across this problem while upgrading projects across eclipse versions. For e.g. junits running well in Mars2.0 did not run on Neon. The following worked for me.

    1. Delete .settings folder. Import project into eclipse.
    2. Remove source folders. Then again use the folders as source folders. e.g - remove src/main/java from build path as source folder. -> Ok -> Again make this folder as source folder. Repeat it for main/resources, test/java, test/resources
    0 讨论(0)
  • 2020-12-13 08:58

    If none of the other answers work for you, here's what worked for me.

    Restart eclipse

    I had source folder configured correctly, and unit tests correctly annotated but was still getting "No JUnit tests found", for one project. After a restart it worked. I was using STS 3.6.2 based of eclipse Luna 4.4.1

    0 讨论(0)
  • 2020-12-13 08:59

    It looks like you're missing the runner definition on your test class, that could be the cause:

    import org.junit.runners.JUnit4;
    @RunWith(JUnit4.class)
    public class BallTest {
    ...
    }
    
    0 讨论(0)
  • 2020-12-13 08:59

    I solved the problem by configuring the build path. Right click on the project(or any of the subfolders)-> Build path -> Configure build path. Once the property window opens up, click on the 'Source' tab and add your src and tst folders. But this alone did not work for me. Strangely, I had to retype the annotations.(Project->clean or restart might also have worked though).

    0 讨论(0)
  • 2020-12-13 09:00

    Sometimes, it occurs when you add Junit Library in Module path. So, Delete it there and add in Class path.

    0 讨论(0)
提交回复
热议问题