Open akrigator opened 1 year ago
It if not obvious but Groups are designed for test selection and order. There are not designed for test dependency.
In your sample, there is no reason to retry the succeed test.
If you use dependsOnMethods instead, it should work as you expect.
@juherr, Here is an example from the 5.7.1 section of https://testng.org/doc/documentation-main.html:
@Test(groups = { "init" })
public void serverStartedOk() {}
@Test(groups = { "init" })
public void initEnvironment() {}
@Test(dependsOnGroups = { "init.*" })
public void method1() {}
Should a fail report include serverStartedOk
or initEnvironment
if some of them are failed?
According to your comment - should not, but this example shows extremely clear that serverStartedOk
and initEnvironment
must be passed before running method1
. No matter is it a first run or rerun of failed tests. More over the behaviour has been changed somewhere between 7.3.0 - 7.6.1 releases. Because of that i'm still guessing that this an defect.
It will depend on what groups are enabled in the runner.
Maybe in the sample, testng-failed.xml should include all the groups which were enabled and were a dependency of the failing test.
@krmahadevan wdyt?
@akrigator - How are you running these tests ? I would expect TestNG to honour the group selection only if it was enabled as part of execution by filtering on groups. I remember streamlining some issues around the group selection which perhaps can explain why you see what you see.
Can you please edit your question and also include the suite xml file/surefire configuration or any other relevant details which will tell us more on the execution mode ?
@akrigator - This is the issue that I was mentioning https://github.com/testng-team/testng/issues/2664
@krmahadevan, i've added a suite xml example. Fill free to request anything also you need from me and thanks for quick involvement
@akrigator - I was guessing that this would be the case :) (You are running without choosing any groups). If you go back and look at the issue I linked earlier, that was what was being discussed in that issue as well.
I think we eventually ended up restoring the old behaviour in TestNG, but sounds like the issue comes back when there are failures ?
I need to first check if dependsOnGroups
is even being honoured here, because there's no clear behaviour clarity when it comes to groups and running a suite that doesnt say which group to run.
There are two interpretations when no group is specified:
@juherr - WDYT ? The tests are being run without any groups. So should we just think that we would like to ignore dependsOnGroups
because there was no group selection involved at all ?
From my points of view: TestNG provides ability to set dependencies via dependsOnMethods
and dependsOnGroups
attributes. DoG helps to simplify setting relations between tests if a dependent test is related to multiple tests, in comparing with DoM. For example, the test class could be overwritten to :
public class DbgTest {
private String test1result;
private String test2result;
@Test
public void test1() {
test1result = "something";
assert true;
}
@Test
public void test2() {
test2result = "something also";
assert false;
}
@DataProvider
public Object[][] dpResults() {
return new Object[][] {
{ test1result },
{ test2result }
};
}
@Test(dependsOnMethods = {"test1", "test2"}, dataProvider = "dpResults")
public void test3(String result) {
assert result != null;
}
}
in this case a rerun of fails will work as expected. But this pattern is hard to be sustained in case of the "group" growing or increasing number of test dependent on the "group".
TestNG Version
7.8.0
Expected behavior
The 7.3.0 version produces testng-failed.xml with passed, failed and skipped tests.
Actual behavior
The 7.6.1 and 7.8.0 produces testng-failed.xml with failed and skipped tests.
Is the issue reproducible on runner?
Test case sample
Suite xml
Contribution guidelines
Incase you plan to raise a pull request to fix this issue, please make sure you refer our Contributing section for detailed set of steps.