'No JUnit tests found' in Eclipse

后端 未结 22 2743
闹比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 09:12

    I was using @RunWith(Parameterized.class) but missed to add the @Parameters annotation in the public static parameters method. After adding the annotation it worked.

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

    Right Click on Project > Properties > Java Build Path > Libraries > select classpath -> add Library -> Junit -> select junit version -> finish -> applay

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

    The run configuration for a test class can create another cause (and solution) for this problem.

    If you go to Run (or Debug) Configurations (using cmd-3 or clicking on the small dropdown buttons in the toolbar) you can see a configuration created for every test class you've worked with. I found that one of my classes that wouldn't launch had a run configuration where the Test Method field had somehow gotten inadvertently populated. I had to clear that to get it to work. When cleared it shows (all methods) in light text.

    I'll add that strangely — maybe there was something else going on — it also seemed not to work for me until I fixed the "Name" field as well so that it included only the class name like the other JUnit run configurations.

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

    I had the same problem and solved like this: I deleted @Test annotation and retyped it. It just worked, I have no idea why.

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

    I think you have created your test classes outside the src folder. You can solve above problem by two way:

    1. Add your package name in java build path->source

    2. Move your package/class in src folder

    I have the same problem and solved in this way both solutions working fine.

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

    Right Click on Project > Properties > Java Build Path > Add the Test folder as source folder.

    All source folders including Test Classes need to be in Eclipse Java Build Path. So that the sources such as main and test classes can be compiled into the build directory (Eclipse default folder is bin).

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