Discussion:
Test for JUnit version?
Roger Whitcomb
2017-07-06 20:53:41 UTC
Permalink
Hi all,
I just realized I have written some JUnit tests that rely on "assertNotEquals" that has just appeared "recently" in JUnit (as in, 4.11 and 4.12, but not 4.10). I'm testing for the presence of JUnit in the classpath in my "build.xml", but is there a way to test for the specific version of JUnit? I see there is a "org.junit.runner.JUnitCore.getVersion()" method, which presumably could be used, but I'm guessing I'd have to write Javascript in my "build.xml" in order to test that.
Anyone have a better idea?

Thanks,
Roger Whitcomb
Roger Whitcomb
2017-07-06 20:42:38 UTC
Permalink
Hi all,
I just realized I have written some JUnit tests that rely on "assertNotEquals" that has just appeared "recently" in JUnit (as in, 4.11 and 4.12, but not 4.10). I'm testing for the presence of JUnit in the classpath in my "build.xml", but is there a way to test for the specific version of JUnit? I see there is a "org.junit.runner.JUnitCore.getVersion()" method, which presumably could be used, but I'm guessing I'd have to write Javascript in my "build.xml" in order to test that.
Anyone have a better idea?

Thanks,
Roger Whitcomb
Stefan Bodewig
2017-07-07 03:57:54 UTC
Permalink
Post by Roger Whitcomb
Hi all,
I just realized I have written some JUnit tests that rely on "assertNotEquals" that has just appeared "recently" in JUnit (as in, 4.11 and 4.12, but not 4.10). I'm testing for the presence of JUnit in the classpath in my "build.xml", but is there a way to test for the specific version of JUnit? I see there is a "org.junit.runner.JUnitCore.getVersion()" method, which presumably could be used, but I'm guessing I'd have to write Javascript in my "build.xml" in order to test that.
Anyone have a better idea?
You can use a <condition> together with <hasmethod> [1] to directly test
for the presence of assertNotEquals.

Stefan

[1] http://ant.apache.org/manual/Tasks/conditions.html#hasmethod

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@ant.apache.org
For additional commands, e-mail: user-***@ant.apache.org
Roger Whitcomb
2017-07-07 14:03:31 UTC
Permalink
Perfect! Somehow missed that ... :) Thank you.

-----Original Message-----
From: Stefan Bodewig [mailto:***@apache.org]
Sent: Thursday, July 06, 2017 8:58 PM
To: ***@ant.apache.org
Subject: Re: Test for JUnit version?
Post by Roger Whitcomb
Hi all,
I just realized I have written some JUnit tests that rely on "assertNotEquals" that has just appeared "recently" in JUnit (as in, 4.11 and 4.12, but not 4.10). I'm testing for the presence of JUnit in the classpath in my "build.xml", but is there a way to test for the specific version of JUnit? I see there is a "org.junit.runner.JUnitCore.getVersion()" method, which presumably could be used, but I'm guessing I'd have to write Javascript in my "build.xml" in order to test that.
Anyone have a better idea?
You can use a <condition> together with <hasmethod> [1] to directly test for the presence of assertNotEquals.

Stefan

[1] http://ant.apache.org/manual/Tasks/conditions.html#hasmethod

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@ant.apache.org For additional commands, e-mail: user-***@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@ant.apache.org
For additional commands, e-mail: user-***@ant.apache.org

Continue reading on narkive:
Loading...