dependsOnGroup reorders methods in dependent tests

475 views
Skip to first unread message

jarek

unread,
Jun 3, 2009, 10:12:26 AM6/3/09
to testng-users
Hi,
I'm wondering if I'm seeing the right behavior of TestNG (5.9), when
it runs methods from tests, that depend on groups.

I have 3 classes:

@Test(groups={"zero"})
public class ZeroTest{

@Test
public void zeroA(){
System.out.println("zeroA");
}

@Test
public void zeroB(){
System.out.println("zeroB");
}


}


@Test(groups={"first"}, dependsOnGroups={"zero"})
public class FirstTest{

@Test
public void firstA(){
System.out.println("firstA");
}

@Test
public void firstB(){
System.out.println("firstB");
}


}

@Test(groups={"second"}, dependsOnGroups={"zero"})
public class SecondTest{

@Test
public void secondA(){
System.out.println("secondA");
}

@Test
public void secondB(){
System.out.println("secondB");
}


}


What I get is:
[testng] [Parser] Running:
[testng] mySuite
[testng] zeroB
[testng] zeroA
[testng] firstB
[testng] secondB
[testng] firstA
[testng] secondA
[testng] ===============================================
[testng] mySuite
[testng] Total tests run: 6, Failures: 0, Skips: 0
[testng] ===============================================

Is it ok, that after all methods from the Zero class were run, methods
from First and Second are *not* 'grouped' together? I mean, it's not
running first *all* methods from one class (First or Second, doesn't
matter), then all methods from the other (remaining) class.
I know, docs state it clear that I cannot expect any order if I use
dependsOnGroups, but what I would expect is that at least all methods
in a class are run together. Am I wrong?

Thanks,
Jarek

Cédric Beust ♔

unread,
Jun 3, 2009, 11:45:18 AM6/3/09
to testng...@googlegroups.com
I improved the sorting algorithm, please try the new version:

http://testng.org/testng-5.10beta.zip

and let me know if it works better.

--
Cedric

--
Cédric


jarek

unread,
Jun 3, 2009, 12:05:04 PM6/3/09
to testng-users
Much better!! Thanks a lot!

[testng] [Parser] Running:
[testng] mySuite
[testng] zeroA
[testng] zeroB
[testng] firstA
[testng] firstB
[testng] secondA
[testng] secondB
[testng] ===============================================
[testng] mySuite
[testng] Total tests run: 6, Failures: 0, Skips: 0
[testng] ===============================================

Cheers,
Jarek
> ***Cédric
> *

Quintanilla

unread,
Jun 5, 2009, 8:59:23 PM6/5/09
to testng-users
Hello Cédric

I'm having issues too with method orders with dependents groups.
But in my case, I'm using several threads.

There is a counter indication of using dependents groups between test
classes and the attribute sequential=true ?

Because the same example, using the parallel=method in the suite and
sequential=true in the testclasses causes skipped methods in the
execution.

Looks like the suite doesn't wait for dependents group in this
particular scenario.
> ***Cédric
> *

Cédric Beust ♔

unread,
Jun 5, 2009, 9:07:20 PM6/5/09
to testng...@googlegroups.com
Can you post a short version of your code and the output?

--
Cedric

--
Cédric


Quintanilla

unread,
Jun 8, 2009, 10:04:30 AM6/8/09
to testng-users
Sure, its similar to jarek's example but using threads

### Classes

@Test(groups={"zero"}, sequential=true)
public class ZeroTest{

@Test
public void zeroA(){
System.out.println("zeroA");
}

@Test
public void zeroB(){
System.out.println("zeroB");
}
}


@Test(groups={"first"}, dependsOnGroups={"zero"}, sequential=true)
public class FirstTest{

@Test
public void firstA(){
System.out.println("firstA");
}

@Test
public void firstB(){
System.out.println("firstB");
}
}


@Test(groups={"second"}, dependsOnGroups={"zero"}, sequential=true)
public class SecondTest{

@Test
public void secondA(){
System.out.println("secondA");
}

@Test
public void secondB(){
System.out.println("secondB");
}
}

### XML

<suite name="MySuite" verbose="0" parallel="methods" thread-count="3">
<test name="MyTest">
<packages>
<package name="jarek"></package>
</packages>
</test>
</suite>


### Output:

[Parser] Running:
Y:\example\testng-jarek.xml

zeroB
zeroA

### Observations:
In the HTML log the others methods appears as skipped

I'm using this approach because our suite is web oriented and is
divided in testClasses with several testMethods.
We prefer to restart some processes (e.g. the browser) per class
instead per method, in order to speed up the suite, that's why we use
the parallel=methods and sequential=true.

What happened to parallel=classes? was deprecated?
> ***Cédric
> *

Cédric Beust ♔

unread,
Jun 8, 2009, 10:33:43 AM6/8/09
to testng...@googlegroups.com
Quick response:  no, parallel="classes" is still supported.

--
Cedric

--
Cédric


Cédric Beust ♔

unread,
Jun 8, 2009, 10:36:37 AM6/8/09
to testng...@googlegroups.com
I don't understand what the problem is, here.  Is it that zeroB() and zeroA() were not run in alphabetical order?

--
Cedric


2009/6/8 Cédric Beust ♔ <cbe...@google.com>



--
Cédric


Quintanilla

unread,
Jun 8, 2009, 11:43:46 AM6/8/09
to testng-users
Hello Cedric!
First at all! Thank you for the quick response.

The problem that I see is that groups first and second don't run, are
skipped. That is normal?

In other hand, maybe I'm misunderstanding the parallel classes
attribute, because when it is used in the XML:

<suite name="MySuite" verbose="0" parallel="classes" thread-
count="3">

The console show this warning:

[Parser] [WARN] Unknown value of attribute 'parallel' at suite
level: 'classes'.

And in the HTML Log, in the methods.html, in the column Thread all my
tests run in "main@3779465" Thread, not in pool-x-thread-x.

For run these tests, testng 5.9 and eclipse plugin are used.










On Jun 8, 9:36 am, Cédric Beust ♔ <cbe...@google.com> wrote:
> I don't understand what the problem is, here.  Is it that zeroB() and
> zeroA() were not run in alphabetical order?
>
> --
> Cedric
>
> 2009/6/8 Cédric Beust ♔ <cbe...@google.com>
>
>
>
> > Quick response:  no, parallel="classes" is still supported.
>
> > --
> > Cedric
>

Quintanilla

unread,
Jun 8, 2009, 12:10:24 PM6/8/09
to testng-users
errata slip:

I'm using testng *5.10* and eclipse plugin

Cédric Beust ♔

unread,
Jun 8, 2009, 12:24:18 PM6/8/09
to testng...@googlegroups.com
You must be using an old jar, here is the output I get:

zeroA
zeroB
firstA
firstB
secondA
secondB
PASSED: zeroA
PASSED: zeroB
PASSED: firstA
PASSED: firstB
PASSED: secondA
PASSED: secondB

Try to run your example from the command line with just the testng jar to confirm.

--
Cédric

Reply all
Reply to author
Forward
0 new messages