by cschiavo_zend on Wed Oct 13, 2010 1:03 pm
I had this problem in a Zend Framework project and it drove me nuts for a long time. Finally I noticed that it was possible to run the test case/class if I moved the file into a different folder, in this case "application". A fresh new project didn't exhibit the same problem: the testing class could be placed anywhere. Then, a fresh new Zend Framework project behaved similarly.
Finally, I examined the differences between my original project and the test ones: the .buildpath settings were different. As it turns out the PHPUnit test cases won't run unless the file is under one of the build paths. I replaced:
<buildpathentry kind="src" path="application" />
with
<buildpathentry kind="src" path="" />
and the problem was solved. Now, why that results in the useless error message "Unable to run PHPUnit session. Only PHPUnit classes can be run as PHPUnit tests." is another mystery, but fortunately it's one I don't have to solve.