Making migration from JUnit to TestNG bit easier

287 views
Skip to first unread message

Lukas Jungmann

unread,
Feb 6, 2012, 2:33:53 PM2/6/12
to testn...@googlegroups.com
Hi Cedric,

I was thinking about making it easier for developers to switch from
JUnit to TestNG. At this point there's an eclipse plugin you're
maintaining but in my eyes it has some limitations - the bigest one is
that it is not that useful for big projects not developed in Eclipse.
I tried to look at the migration itself from a different
perspective - TestNG allows one to run JUnit 3 tests, so why not to
try to extend it a bit to so it can recognize JUnit tests
automatically and run them if needed? I believe this could also help
TestNG adoption a lot.

All one will have to do will be - for Ant based projects - replace
junit ant task with testng one and run it in new "mixed" mode - this
will tell it that it should try to find junit library on the
classpath, check passed in files whether there are any JUnit tests and
if so, then run them in junit mode (which has been extended to handle
also JUnit 4 tests).

Also note that I don't plan to work on bringing particular TestNG
features to JUnit. Only on making it possible to run existing JUnit
tests through TestNG (if needed).

I made all changes required for this to work in my forked
repository[1], created full diff between official TestNG repository
and my fork to make review easier[2] and created a wiki page
describing the motivation, particular commits etc[3]. I tested these
changes also on some existing modules from NetBeans codebase and with
my changes I'm able to successfully run them using TestNG (eventhough
they're mostly written in JUnit 3 format) without almost any migration
issues.

I will be happy if you'd consider this contribution for inclusion
in the official TestNG distribution and definitely will appreciate any
feedback you may have on this (there's already pull request for
this[4]).

Thanks,

WBR,
--lukas

[1]: https://github.com/lukasj/testng/
[2]: http://wiki.netbeans.org/wiki/images/d/dc/Testng-6.4beta.diff.zip
[3]: http://wiki.netbeans.org/TestNG_MixedMode
[4]: https://github.com/cbeust/testng/pull/139

Cédric Beust ♔

unread,
Feb 6, 2012, 5:33:01 PM2/6/12
to testn...@googlegroups.com
Hi Lukas,

Just wanted to send you a quick acknowledgment of your email: this looks some major work so I'd like to take some time to read your email and patch  fully before commenting further.

Thanks again for doing all this work!

-- 
Cédric





--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To post to this group, send email to testn...@googlegroups.com.
To unsubscribe from this group, send email to testng-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-dev?hl=en.


Lukas Jungmann

unread,
Feb 7, 2012, 6:45:13 AM2/7/12
to testn...@googlegroups.com
Hi Cedric,

2012/2/6 Cédric Beust ♔ <ced...@beust.com>:


> Hi Lukas,
>
> Just wanted to send you a quick acknowledgment of your email: this looks
> some major work so I'd like to take some time to read your email and patch
>  fully before commenting further.

Thanks for letting me know. I've found one bug in my patch and that's
that public abstract class with suite method is not treated as JUnit
test - I already put this under known issues[1]. This shouldn't be
hard to fix :-)

I've also added a section about how -testclass and -methods options
translates to testng.xml[2] with my patch as this part may be
interesting to others as well.

Regards,
--lj

[1]: http://wiki.netbeans.org/wiki/index.php?title=TestNG_MixedMode&diff=51464&oldid=51463
[2]: http://wiki.netbeans.org/wiki/index.php?title=TestNG_MixedMode&diff=51463&oldid=51462

Reply all
Reply to author
Forward
0 new messages