|
|
|
I do have "Make" in the "Before launch" section selected (i.e. it is checked), and typically do. Yesterday when I was experiencing the issue, I even deleted the IDEA out directory (i.e. the "Project Compiler Output" directory), did a full project rebuild (Build | Rebuild Project), and then tried running the JUnit test. I still received the "com.mycompany.MyUnitTest is not derived from TestCase. Do not provide method name." error. I tried this several times, and even tried renaming the test method, and the test class and then rebuilding. Nothing worked. It was only after I shut down IDEA, deleted the system cache, and restarted IDEA, and rebuilt the project, that the issue was resolved.
Also, if IDEA wasn't finding the compiled class (or at least the version of it with the new method), that wouldn't explain why the new test ran fine – and was listed in the list of tests run in the left side tree – when I ran all tests in the class. But then when I tried to run that new test by itself immediately afterwards, it still gave the error. FYI: I ran into this issue again today. But this time on a test that I had not modified. In fact, nothing in the test class had changed. I made a minor change in the tested class, and when I went to run the test for it, I received the "not derived" error. As before, while I can run all the tests in the class, I cannot run the individual test.
You are running the test method via the Run configuration combobox in the IDEA toolbar, right?
Is the test method icon there is shown red-crossed, like in the acreenshot attached? >You are running the test method via the Run configuration combobox in the IDEA toolbar, right?
Sometimes. Frequently I simply hit Ctrl+Shift+F10 while my cursor is in the test method. >Is the test method icon there is shown red-crossed, like in the screenshot attached? No. They were showing as valid. That's the first thing I look at if I have trouble running a test. I know this is a hard one to troubleshoot since it is very intermittent. And I have no way to reliably reproduce it for you. The next time it happens, is there anything I can grab for you? A log file or memory snapshot? Well, it seems the test class does not get recompiled on run.
Next time the thing occurs, could you please note the test source class timestamp, and the corresponding .class file timestamp (should be found in your compiler output directory)? Thank you. And BTW, you are not using Ant, aren't you? >And BTW, you are not using Ant, aren't you?
I do use Ant. But, the ant script copies all the sources to a new directory (for some token replacements) and compiles them to a different target directory than the 'out' directory that IDEA compiles to. That's done purposefully to prevent IDE caching problems (and because the Ant script does a clean build and deletes its output directory). So for all intents and purposes, IDEA's compiling and test runs are completely isolated from Ant's compiling and test runs. Is the test class compiled by Ant?
Is Ant target set up to run before make? >Is the test class compiled by Ant?
Only when I do a full build via Ant. But it is compiled into a different directory then when IDEA compiles a test class.
>Is Ant target set up to run before make? [Edit] I ran into this again today. So as requested:
>Next time the thing occurs, could you please note the test source class timestamp, and the Both the .java source file and the .class file have a timestamp of 2008-01-15 15:26 However, I may have found a contributing factor to the issue. My project comprises of several modules. Most of the modules do not change frequently. The one"primary" module is currently the one being heavily developed. I have a separate module defined for the TRUNK, and the various release branches. I do this since it is an easy way to handle branching. (We branch every month or two.) When a new branch is created, I can copy the TRUNK module definition, and place it in the new branch's directory: <module-root>/TRUNK/moduleName-TRUNK.iml <module-root>/TRUNK/src/main/java <module-root>/TRUNK/src/test/java <module-root>/TRUNK/ide-out/classes <module-root>/TRUNK/ide-out/test-classes <module-root>/RB1/moduleName-RB1.iml <module-root>/RB1/src/main/java <module-root>/RB1/src/test/java <module-root>/RB1/ide-out/classes <module-root>/RB1/ide-out/test-classes <module-root>/RB2/moduleName-RB2.iml <module-root>/RB2/src/main/java <module-root>/RB2/src/test/java <module-root>/RB2/ide-out/classes <module-root>/RB2/ide-out/test-classes etc this allows me to have all my configurations of the release branch match the trunk at the time the release branch was created. Note that my compile target directories are different. I then can add or remove a release branch IDEA module or the TRUNK module to the IDEA project as necessary. Sometimes I may have the TRUNK and a Release Branch module added to the project at the same time. In this instance, when I received the error, I commented out an @Ignore annotation on a test on the Trunk. (It was for some functionality originally planned for the last release, but later postponed. So the ignored test is on the last release branch). After commenting out the @Igonre annotation, I tried to run that individual test via ctrl+shirt+F10 (with the cursor on the test name). It was then that I received the "not derived" error. (I then grabbed the timestamps shown above). I was able to successfully run all tests in the class (by having the cursor on the class name and hitting ctrl+shift+F10). But even after doing that, I could not run the individual test without getting the "not derived" error. I then removed the release branch modules from the project, leaving only the TRUNK module. I then tried to run the individual test, and it ran successfully. I then added the release branch module back, and the test still ran fine. Note that I have worked, sometimes for several days or even weeks, with the TRUNK and a release branch module added/attached to the project. So it might be that on some occasions the caching between the modules gets confused since each module (obviously) has identical classes. Is that possibly the issue? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Since IDEA does not recompile the file before run, it cannot find the corresponding method.