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
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.
Right Click on Project > Properties > Java Build Path > Libraries > select classpath -> add Library -> Junit -> select junit version -> finish -> applay
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.
I had the same problem and solved like this: I deleted @Test annotation and retyped it. It just worked, I have no idea why.
I think you have created your test classes outside the src folder. You can solve above problem by two way:
Add your package name in java build path->source
Move your package/class
in src
folder
I have the same problem and solved in this way both solutions working fine.
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).