• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[ANT] Can I run a junit test suite in a multi-thread manner?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I've got so many junt test cases in the suite that it takes me too much time to have a run using ANT.

I'm wondering whether I can make this running in a multi-thread manner so that I can save time.

Can anybody please help?
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kent and welcome to Javaranch, have you looked at forking the process to run JUnit?
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kent,

sorry, I don't know if it is possible with JUnit, but if you need "real" multithreading in tests TestNG offers easy to use support and it is very similar to JUnit tests.

Marco
 
Kent Chan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Martijn.

Yes, I did. And there seems to be nothing about what I want.

Martijn Verburg wrote:Hi Kent and welcome to Javaranch, have you looked at forking the process to run JUnit?

 
Kent Chan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can I use TestNG to run Junit tests?

I know nothing about TestNG. So this could be a stupid question.


Marco Ehrentreich wrote:Hi Kent,

sorry, I don't know if it is possible with JUnit, but if you need "real" multithreading in tests TestNG offers easy to use support and it is very similar to JUnit tests.

Marco

 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, this is definitely not a stupid question

In fact TestNG offers the possibility to run JUnit tests! I've only tested this feature once and unfortunately it seems that it can only detect and run JUnit 3 tests (i.e. methods/classes with the necessary "test" prefix or suffix). Without more research I couldn't find a quick solution to run JUnit 4 tests. On the other hand the basic functionality is almost nearly the same in TestNG and JUnit 4. Both are heavily based on annotations and share a set of common features (for example @Test annotation for test methods). What's definitely annoying for developers coming from JUnit is the difference in assert statements. TestNG and JUnit mostly share the same assertXYZ() methods but unfortunately the order of expected and actual values is just inverse

In short: If you don't prefer a specific unit testing framework I'd recommend TestNG. IDE and tools support is almost as good as for JUnit today. And TestNG offers almost the same features as JUnit plus some more which makes it for example more interesting to even create integration or acceptance tests. Multithreaded testing is possible (not only to speed up the test process) and some more.
On the other hand, if you have to deal with existing JUnit tests it's probabyl only a reasonable alternative if you a) can convert the JUnit tests or b) find a way to run JUnit tests from TestNG. Unfortunately I can't tell you more about it.

Marco
 
Kent Chan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marco,
That sounds pretty cool.

I'll do some investigation to see if I can integrate TestNG with JUnit.

Besides, what you said about Test NG's ability to "even create integration or acceptance tests" also interested me. I'm actually looking for something like this. Thanks!
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad to here that my information was useful even though it doesn't immediately solve your problem

The features for integration or higher-level tests was one thing which I found interesting, too, while doing some research to find a suitable testing framework just a few weeks ago.
The point is that TestNG offers easy support to form groups/suites or groups of groups of tests etc. which is even configurable with external XML config files. This lets you define "dependend" tests which is one thing that JUnit explicitly tries to avoid. But for integration tests this offers you an easy way to reuse multiple existing unit tests to exercise entire use cases or scenarios. And you have more features to explicitly create shared fixtures (like a dummy database etc.) which you will probably need, when executing multiple dependend tests to test a use case or similar. But I'm sure the TestNG documentation can explain this more understandable

Marco
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use groboutils
http://groboutils.sourceforge.net/testing-junit/using_mtt.html
 
reply
    Bookmark Topic Watch Topic
  • New Topic