Error running unit tests in Eclipse

I was using Eclipse to run my project’s unit tests and I received this error right away:

The project: MyDependantProject which is referenced on the classpath, does not exist.

I took a look at my projects Java Build Path configuration, and “MyDependantProject” was listed there.

Next, I took a look at the JUnit Run Configuration.  This was more alarming as look at the blank line.  That was where I should have saw “MyDependantProject” listed:


I went back to my Java Build Path and I removed “MyDependantProject” in attempt to force a different error (as I thought once I re-added it, that blank line above would go away).  This time when I ran my unit tests, I received this error:

org.eclipse.jdt.internal.core.JavaModel cannot be cast to org.eclipse.jdt.core.IJavaProject

The combination of these two errors made me reflect upon my workspace.  I knew I had just created this Eclipse workspace the other day.  I looked a little closer and I realized that  the name of my workspace was the same as the name of one of my projects in the workspace.

Searching Google, you will find doing this will cause a myriad of problems that manifest in different ways.   So my solution was just to rename my workspace to something that was not the name one of the projects.


About stevewall123

I am a Lead Software Engineer in Minneapolis working for Thomson Reuters. I am currently working on projects using Java, JavaScript, Spring, Elasticsearch, Hazelcast, Liquibase and Tomcat. Previously, I used C#, GWT, Grails, Groovy, JMS and JBoss Drools Guvnor. In the past I have worked on projects using J2EE, Swing, Webwork, Hibernate, Spring, Spring-WS, JMS, JUnit and Ant.
This entry was posted in Miscellaneous and tagged . Bookmark the permalink.

2 Responses to Error running unit tests in Eclipse

  1. Sam says:

    thanks for post

  2. Aparajith says:

    Thank you, your solution saved my day

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s