testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.99k stars 1.02k forks source link

In suite file parallel="tests" does not work correctly when the test tag contains muliple classes #761

Open ptsiakos77 opened 9 years ago

ptsiakos77 commented 9 years ago

Given the suite file:

``` ```

In this suite file: (parallel="tests" thread-count="2" ) the execution sequence in the thread of the "First Test" is: 1st-> Execute @BeforeClass method of BasicTest1 2nd-> Execute @BeforeClass method of BasicTest2 3rd-> Execute first @Test method of BasicTest1 2nd-> Execute first @Test method of BasicTest2 .... and so on....

I would expect first the complete execution of BasicTest1: @BeforeClass and the @Test methods Then the complete execution of BasicTest2: @BeforeClass and the @Test methods since preserve-order="true"

Note: The sequence execution for the @Test methods inside a class is defined using the dependsOn and alwaysRun=true attributes

roydekleijn commented 8 years ago

I'm facing the same issue, is there a solution for this ?

juherr commented 8 years ago

Could you pull-request a new test case which shows the issue? You can add a new test class or update/use an existing one from https://github.com/cbeust/testng/tree/master/src/test/java/test/thread

roydekleijn commented 8 years ago

I created an example project here: https://github.com/roydekleijn/testngParallelIssue

I'm getting the following output: Running TestSuite Before group 1 | class 1 | thread: 10 Before group 2 | class 1 | thread: 11 Group 1 | Class 1 | test 1 | thread: 10 Group 2 | Class 1 | test 1 | thread: 11 Group 1 | Class 1 | test 2 | thread: 10 Group 2 | Class 1 | test 2 | thread: 11 Before group 1 | class 2 | thread: 10 Before group 2 | class 2 | thread: 11 Group 1 | Class 2 | test 1 | thread: 10 Group 1 | Class 2 | test 1 | thread: 11 Group 1 | Class 2 | test 2 | thread: 10 Group 1 | Class 2 | test 2 | thread: 11 Before group 3 | class 1 | thread: 11 Before group 4 | class 1 | thread: 10 Group 4 | Class 1 | test 1 | thread: 10 Group 3 | Class 1 | test 1 | thread: 11 Group 3 | Class 1 | test 2 | thread: 11 Group 4 | Class 1 | test 2 | thread: 10 Before group 3 | class 2 | thread: 11 Before group 4 | class 2 | thread: 10 Group 3 | Class 2 | test 1 | thread: 11 Group 1 | Class 2 | test 1 | thread: 10 Group 3 | Class 2 | test 2 | thread: 11 Group 1 | Class 2 | test 2 | thread: 10

While I was expecting the following:

What can I do differently ? Roy de Kleijn

On Mon, Dec 14, 2015 at 11:43 AM, Julien Herr notifications@github.com wrote:

Could you pull-request a new test case which shows the issue? You can add a new test class or update/use an existing one from https://github.com/cbeust/testng/tree/master/src/test/java/test/thread

— Reply to this email directly or view it on GitHub https://github.com/cbeust/testng/issues/761#issuecomment-164406131.

[image: --] Roy de Kleijn [image: http://]about.me/roydekleijn http://about.me/roydekleijn?promo=email_sig

juherr commented 8 years ago

In fact, as I understand:

By default, the parallel value is "false". In other words, every things from Group1 should be run in the same thread, same for Group2, Group3 and Group4. As you failed some outputs, I'm not able to say without running the project if I see an issue or not.

If you want a different parallel behavior on tests, you should try it in different suites (surefire accepts many files)

roydekleijn commented 8 years ago

All I want is:

Having multiple 's in testng.xml, some with different behavior..

How can I execute some 's in parallel and some not? using the same testng.xml ?

On Wed, Dec 16, 2015 at 4:33 PM, Julien Herr notifications@github.com wrote:

In fact, as I understand:

  • means you want in threads.
  • means you don't want threads for classes and methods.

By default, the parallel value is "false". In other words, every things from Group1 should be run in the same thread, same for Group2, Group3 and Group4. As you failed some outputs https://github.com/roydekleijn/testngParallelIssue/blob/master/src/test/java/group2/TestClass2.java#L15, I'm not able to say without running the project if I see an issue or not.

If you want a different parallel behavior on tests, you should try it in different suites (surefire accepts many files)

— Reply to this email directly or view it on GitHub https://github.com/cbeust/testng/issues/761#issuecomment-165144973.

[image: --] Roy de Kleijn [image: http://]about.me/roydekleijn http://about.me/roydekleijn?promo=email_sig

juherr commented 8 years ago

How can I execute some 's in parallel and some not? using the same testng.xml ?

As I said, IMO it is not supposed to work.

roydekleijn commented 8 years ago

ok, fair enough.. I thought you ment my implementation...

On Wed, Dec 16, 2015 at 9:38 PM, Julien Herr notifications@github.com wrote:

How can I execute some 's in parallel and some not? using the same testng.xml ?

As I said, IMO it is not supposed to work.

— Reply to this email directly or view it on GitHub https://github.com/cbeust/testng/issues/761#issuecomment-165232065.

[image: --] Roy de Kleijn [image: http://]about.me/roydekleijn http://about.me/roydekleijn?promo=email_sig