Hi All,
I'm trying to combine hard and soft dependencies for a test method, to
do this I wanted to execute tests based on priority across dependent
methods. The way I understand how testng selects its test methods to
run is it looks to see what methods are free, based on dependencies,
then executes those methods in the order specified by
IMethodSelector. I think by default it uses priority to set the order
of the methods to execute. TestNG runs those methods then checks to
see which method is free. What I'm trying to do is after the methods
are sorted, and the first method is run, TestNG goes back to look at
the free methods to resort based on priority. So, the free test
methods are retrieved and resorted after every test method is run. It
doesn't look like this is possible, based on how TestRunner executes
the tests and DynamicGraph gets the free nodes. I've tried writing a
method interceptor that, given a list of methods, it would return a
list with only one method (the one with the lowest priority), however
TestRunner marks all the tests given to the method interceptor as
finished even if they weren't run.
Another view of what I'm trying to do is the combination of hard and
soft dependencies, where the hard dependency is the dependsOnMethods
and the soft dependency is the priority. Below is an example of what
I'm trying to do. The issue is testD needs testE to have not been
executed yet, but testE's only dependency is testB.
public class Tests {
@Test
public void testA() {
System.out.println("Test A - Priority=0");
}
@Test
public void testB() {
System.out.println("Test B - Priority=0");
}
@Test(priority = 1, dependsOnMethods ={"testA"})
public void testC() {
System.out.println("Test C - Priority=1");
}
@Test(priority = 2, dependsOnMethods ={"testB", "testC"})
public void testD() {
System.out.println("Test D - Priority=2");
}
@Test(priority = 3, dependsOnMethods ={"testB"})
public void testE() {
System.out.println("Test E - Priority=3");
}
}
The output of running this is:
Test A - Priority=0
Test B - Priority=0
Test C - Priority=1
Test E - Priority=3
Test D - Priority=2
What I want to happen is:
Test A - Priority=0
Test B - Priority=0
Test C - Priority=1
Test D - Priority=2
Test E - Priority=3
So rather than the order of execution being:
Free Methods | Executed Methods
(TestA, TestB) | TestA -> TestB
(TestC, TestE) | TestC -> TestE
(TestD) | TestD
I want the order of execution to be performed as so:
Free Methods | Executed Methods
(TestA, TestB) | TestA
(TestB, TestC) | TestB
(TestC, TestE) | TestC
(TestD, TestE) | TestD
(TestE) | TestE
Note: Above free methods were sorted by priority
Is there any way to accomplish this type of run? I could make E
depend on D, but I want E to run even if D fails and only if B passes.
Thanks for your help,
Steven
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to
testng-users@....
To unsubscribe from this group, send email to
testng-users+unsubscribe@....
For more options, visit this group at
http://groups.google.com/group/testng-users?hl=en.