Question

My problem is that test cases can not see the newly compiled files. During my program I programmatically change a input program (called InputProgram), and then compile that and save it in a proper folder in bin. Test cases related to the input program (provided as Jar file) are also extracted and are saved in a proper document in bin directory.

The first iteration works completely fine. In fact, if I change the InputProgram and the applied changes caused any failure in test cases, the test cases can catch them. (-:

However, after the first iteration, if I change the program again, the test cases can not see the changes, and return me the results for the first changes (first iteration). In fact, it can not see the newly compiled file. Note that, I check the newly created program files (.class), and I can see changes are there. Therefore, the compiler process (done programmatically) works fine.

I delete the test cases (.class) files from bin directory before executing second iteration and surprisingly I saw the test cases can still be run, but again based on the old version. It seems eclipse does not load the new version of files.

I also clean bin directory (project->clean) during execution, but still no success. I also replaced the old version of testcases with new ones (extracted again from jar file), but again no success.

Overall, I need Jave instructions that I can programmatically tell the eclipse to load newly compiled files.

Not sure it help, but I use this instructions to run a JUnit test case:

Result result = JUnitCore.runClasses(testCase);
for (Failure failure : result.getFailures()) 
   System.out.println(failure.toString());
Was it helpful?

Solution

If you modify a file from outside eclipse, you have to right click on the project and refresh it [F5].

enter image description here

Now, if we're talking about two eclipse projects (one that has the code to be tested and another with the code to test it), I'd suggest you to create a dependency between then, like this

enter image description here

where the test project build path has

enter image description here

this way, the main project is still free of testing code, and your testing code can see immediately any change in the main project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top