Hello there guys,

Ive read two threads on parallelizing junit tests on this list and a
lot of info on the web itself.

Ill point out our current problems with <parallel> tag and
parallel-junit project and then tell about the patch we have created
for ant 1.7.1 which allows parallelized running of perTest tests.

The parallel tag surely works fine, but I have to decide which tests
will run in each thread, therefore if some thread stops in, lets say 3
minutes, the other threads might run up to 10 minutes. If the first
thread did not stop at all, it could have run the tests designed for
the second thread. Therefore parallel surely works, but doesnt work as
a thread pool (of course, its not its intention at all)... so its not
the best solution for running JUnit tests in parallel.

So lets think about parallel-junit project.
The issue occurs with integration tests which use Selenium as its main
tool. As we do not want to open a browser window for each test method,
the Selenium reference is saved as a static reference in our BaseTest
class. (Not so cute but this is the only solution  - @BeforeClass
initilizing it, @AfterClass destroying it - appart from ThreadLocal
issues).
If I run all tests in the same VM and use Parallel JUnit TestSuite, it
will give me ackward problems due to mutual access to the Selenium
static variable... so I had to run it in differente VM's but who
decides which tests run in which VM? Ant... not Parallell JUnit...

Therefore our solution was to simply replace one method (and a few
minor methods - which can be refactored, of course) to allow JUnitTask
to accept the number of threads to run in parallel and use workers to
delegate the testing to.
The whole solution took less than 50 lines I believe and work with
perTest mode just fine.

It works fine, running all tests in parallel. Who can benefit from it?
Those who run their tests in multi-core machines can simply change
their build.xml file by adding an attribute and thats it.

What do you think? Oppinions? Suggestions? Problems? Is this a desired
feature for JUnitTask? Should I send in the patch to the list?

Regards

Guilherme Silveira

-- 
Guilherme Silveira
--------------------------------------------------
[EMAIL PROTECTED]
Caelum - Ensino e Soluções em Java
www.caelum.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to