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
Try this
Right Click on the Unit Test Class,
Now Run the test!
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.
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
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 {
...
}
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).
Sometimes, it occurs when you add Junit Library in Module path. So, Delete it there and add in Class path.