开发者

Cant see changes in .java file when running Junit with Eclipse before mvn install

I have multi module maven project. The technologies I use is Spring and Struts. I created test case and run it as :

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContextSimpleTest.xml" })
public class CurrencySpeakerTest

Everything is fine... until I make some changes in source... I cant see them until i run mvn install on the parent project. Whats wrong? I tried to look into the debug configuration but I cant find the place where its said to look on compile source instead of .java files... I think this is the reason that junit is running the .class files instead of real one... anybody has any idea about that?


I have 3 module app ... they are build with parent module. Parent module is also the imported project in eclipse.I do the changes in one of three module in the test folder. I hit refresh and I do clean/build eclipse project manually ( if i enable automatically build it wont change anything). I run the test as JUnit with eclipse dialog. Eclipse seems not to see the changes in edited test file (.java).

Maybe this has something to do with the one main project which includes the other modules? What is strange is that... if I edit any other classes not in the test folder and run web app with tomcat plugin, Eclipse sees the changes there?


I use mvn clean and mvn install but this is not the issue. I use Eclipse to run the test but the Eclipse debugger cant see the changes in the code... for eg if I add System.out.println() somewhere and put the breakpoint there I run the test and Eclipse doesnt stop there because it looks somehow on the old code (I assume the .class file)...or if I delete the line,edit some String...nothing... it seems to point on the .class...why is that?开发者_如何学编程 Refresh and clean/build eclipse project doesnt work.


When I delete the target from my module where i write the test I got exception below. Which makes my theory true that eclipse is looking into compiled code and cant see the source... Why is that?

Class not found pl.erif.utils.CurrencySpeakerTest java.lang.ClassNotFoundException: pl.erif.utils.CurrencySpeakerTest at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


you may need to run a clean first

mvn clean compile

Are you editing java files outside of eclipse? If yes, you may need to hit f5 to refresh it. (It normally should detect changes)

If not, are you using the build automatically option in eclipse?


I had the same issue. It was due to a defective .classpath. Removing this .classpath and re-importing the project, generates a correct .classpath and fixed the environment. To find more details make sure that eclipse is not generating the class files of your testcase in a wrong directory.

Ref: Unit test class runs old version in eclipse

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜