Basically the source code I am using requires a very specific JUnit test version such as:
lucene-test-framework-XX.jar
The compiled Lucene test-framework library.
Depends on junit 4.10.x (not 4.9.x, not 4.11.x), and Apache Ant 1.7.x (not 1.6.x, not 1.8.x)
However, I am new to Eclipse, where and how do I change the JUnit to 4.10.x?
Thanks a lot in advance!
I have changed mine out in the past by (specifically) removing the prior, then adding the specific JUnit (External) JAR in my project properties' library settings. The steps are as below:
(source: aggroculture.com)
Although the question is how to use a very particular version, the title of the question would also be valid for switching just between JUnit3 and JUnit4. This answer says how to do this.
Since quite a long time the junit library is part of the eclipse distribution. In eclipse Kepler one can switch between JUnit3 and JUnit4, both covered by the effective JUnit Release 4.11.0 (because JUnit3 is still compatible with JUnit4).
Right click on your project, select BuildPath/ConfigureBuildPath and select the tab Libraries. Let's suppose there is the library JUnit3 listed and you want to switch to JUnit4. Select the entry JUnit3, then the button "Remove", then "Add library". In the following wizard you choose "JUnit", "next", "JUnit4" in the dropdown and "Finish".
Maybe you have noticed in the ProjectExplorer that the JUnit4-Library - in contrast to JUnit3 - includes also the hamcrest-core library (which provides powerful matchers).
The problem, at least in Eclipse Luna SR1/SR2, is that Eclipse seems to prioritize the packaged plugin with JUnit 4.11 in "eclipse/plugins/org.junit_4.11.0.v201303080030". Even after trying the answer above to force the version I needed, I kept getting the same test errors so it seems that Junit 4.11 was still being used.
The only solution that has worked so far for me is to replace the junit.jar in that directory (eclipse/plugins/org.junit_4.11.0.v201303080030) with the version I wanted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With