junit not using the newest file

夙愿已清 提交于 2019-12-18 07:53:05

问题


I use junit automatically installed by maven. When I run the maven test my tests work fine. But when I call the Eclipse JUnit test it doesn't use the current version of the test class.

E.g. if I change a assertTrue() into a assertFalse() I get the same result. This is driving me crazy.

Automatic build for the project is on. Why does JUnit use some old crap?

Thanks for the help. A maven clean and a eclipse clean fixed the problem. Weird...


回答1:


Most possibly Maven compiles to ./target/classes while Eclipse usually compiles to ./bin/classes.

You should try the http://m2eclipse.sonatype.org/ plugin for Eclipse that helps out easing the differences between Maven and Eclipse.




回答2:


So, go to directory in which maven copied junit file from junit repository, then check the junit version. so after thath, right click on your project under eclipse than select "Buildpath"> "add library" then select "Junit" next select "junit version" tehn continue. after clean your project, build it, finally launch it.




回答3:


I had the same problem and managed to solve it by manually entering the proper output folder for the compiled tests in "Java build path" under the project properties.

In my case, I wanted the tests to end up in ./target/test-classes.

I think it didn't work at first because Eclipse put the compiled tests either in the wrong folder (.bin/classes) or the default output folder (./target/classes).



来源:https://stackoverflow.com/questions/6161267/junit-not-using-the-newest-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!