Tuesday, August 10, 2010

Eclipse Java test case cannot be found in a project?

Eclipse said "No tests found with test runner 'JUnit 4'". The answer in JUnit FAQ does not fix my case. And the answers on stackoverflow did not help as well. Later I figured out that the reason of the problem was that I did not properly organize the test cases in my project.

The Junit FAQ has a good suggestion. I have a default src directory for the source and a test directory for the test cases. In order to let the runner find the test case, the test directory has to be a Source Folder, not just a directory created in the project directory.