Run As JUnit not appearing in Eclipse - using JUnit4
Solution 1
The problem is with the way you are trying to access and run java files in eclipse. You should be observing this empty 'J' icons on your java files. It is a classpath problem, when you click, you are actually accessing the file from the classpath.
To view the Java file, you have to add a reference to your project in the classpath and move it to the top of the classpath list.
Once you do that, then you should be able to run your junits.
Solution 2
I had the same issue, and I restarted eclipse and got "Run as JUnit test" back. Looks like a bug in eclipse.
rawkfist0215
experience with Java RoR AngularJS Angular Typescript JQuery SASS Gulp ActionScript
Updated on July 05, 2022Comments
-
rawkfist0215 almost 2 years
I'm trying to write JUnit4 tests for my web app, and they had been working fine previously. However, now when I try to run the tests by right clicking the class file -> Run As -> JUnit Test I don't see that option. I think it could be because a colleague committed some Eclipse settings/property files on accident that messed with mine. I'm using Eclipse Helios on a Mac running 10.6.X.
I noticed that the icons on the test classes changed from the "filled" J to a "bubble" J and I'm not sure if that is signifying some kind of problem:
I've double checked and made sure that JUnit4 is on my Build Path, and I've gone to the Eclipse -> Preferences -> JUnit pane and verified there are JUnit4 imports being used.
My test classes look like this:
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration( { "classpath*:/resources/action-test-appconfig.xml" }) @Transactional public class UserControllerTest extends BaseStrutsTestCase<UserController> { /** * Tests the ability of a user to change their login username * @throws Exception */ @Test public void testChangeLogin() throws Exception {
Any thoughts and suggestions are appreciated.