You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Stefan Bodewig <bo...@apache.org> on 2006/03/01 06:00:21 UTC

Re: svn commit: r381780 - in /ant/core/trunk: WHATSNEW docs/manual/OptionalTasks/junit.html src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java

On Tue, 28 Feb 2006, <jg...@apache.org> wrote:

> +                Class junit4TestAdapterClass = null;
> +                // Note that checking for JDK 5 directly won't work; under JDK 4, this will already have failed.
> +                try {
> +                    if (loader == null) {
> +                        junit4TestAdapterClass = Class.forName("junit.framework.JUnit4TestAdapter");
> +                    } else {
> +                        junit4TestAdapterClass = Class.forName("junit.framework.JUnit4TestAdapter", true, loader);
> +                    }
> +                } catch (ClassNotFoundException e) {
> +                    // OK, fall back to JUnit 3.
> +                }
> +                junit4 = junit4TestAdapterClass != null;
> +

I haven't looked into the implemenation of JUnit4TestAdapter so I
have to ask you 8-)

Even if I have JUnit 4 on my CLASSPATH I can still use JUnit 3 style
of tests (no annotations, naming conventions instead).  Will this
patch still allow me to run those tests?  Or will wrapping the tests
in a JUnit4TestAdapter force me to use annotations?

If JUnit would build in Gump (somebody seems to have forgotten to
check in a file) we'd already know since Gump will provide JUnit 4
to allmost all builds while most of them (including Ant) still use
JUnit 3 style tests.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: svn commit: r381780 - in /ant/core/trunk: WHATSNEW docs/manual/OptionalTasks/junit.html src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java

Posted by Jesse Glick <je...@sun.com>.
Stefan Bodewig wrote:
>> I will however patch JUnitTestRunner a tiny bit to be able to run 
>> JUnit 3 tests on JDK 1.4 if your classpath contains JUnit 3
>> _before_ JUnit 4.
> 
> This probably works that way right now, I'd expect Class.forName for 
> JUnit4TestAdapter to throw and exception because of the class file 
> version on JDK 1.4 and then JUnitTestRunner falls back to the old 
> behaviour.

That's not how it worked (cf. my "tweak" patch): just starting the task 
would fail right away since the JUnitTaskMirrorImpl statically refers to 
TestCase, which in junit-4.0.jar is built with -source 1.5.

-J.

-- 
jesse.glick@sun.com  x22801  netbeans.org  ant.apache.org
         http://google.com/search?q=e%5E(pi*i)%2B1


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: svn commit: r381780 - in /ant/core/trunk: WHATSNEW docs/manual/OptionalTasks/junit.html src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 01 Mar 2006, Jesse Glick <je...@sun.com> wrote:
> Stefan Bodewig wrote:

>> Will this patch still allow me to run those tests?  Or will
>> wrapping the tests in a JUnit4TestAdapter force me to use
>> annotations?
> 
> No, you can still use the 3-compatible tests as before.

Great.

> You do need to be running JDK 5+

Yes, I know that.

> I will however patch JUnitTestRunner a tiny bit to be able to run
> JUnit 3 tests on JDK 1.4 if your classpath contains JUnit 3 _before_
> JUnit 4.

This probably works that way right now, I'd expect Class.forName for
JUnit4TestAdapter to throw and exception because of the class file
version on JDK 1.4 and then JUnitTestRunner falls back to the old
behaviour.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: svn commit: r381780 - in /ant/core/trunk: WHATSNEW docs/manual/OptionalTasks/junit.html src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java

Posted by Jesse Glick <je...@sun.com>.
Stefan Bodewig wrote:
> I haven't looked into the implemenation of JUnit4TestAdapter so I
> have to ask you 8-)

Sure, was expecting some questions here...

> Even if I have JUnit 4 on my CLASSPATH I can still use JUnit 3 style
> of tests (no annotations, naming conventions instead).

Yes.

> Will this patch still allow me to run those tests?  Or will wrapping the tests
> in a JUnit4TestAdapter force me to use annotations?

No, you can still use the 3-compatible tests as before.

You do need to be running JDK 5+ since the JUnit team decided to compile 
even the compatibility classes with -source 1.5 and against JDK 5 
classes like StringBuilder, which Ant can't work around. I will however 
patch JUnitTestRunner a tiny bit to be able to run JUnit 3 tests on JDK 
1.4 if your classpath contains JUnit 3 _before_ JUnit 4. Not very much 
help but could make transition a bit easier for some folks: just include 
both versions of JUnit on your classpath in order, and you will be able 
to run JUnit 3 tests always, and 4 tests under JDK 5+.

-J.

-- 
jesse.glick@sun.com  x22801  netbeans.org  ant.apache.org
         http://google.com/search?q=e%5E(pi*i)%2B1


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org