Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@BeforeGroups ignores dependsOnGroups #2804

Open
2 of 7 tasks
schroeca opened this issue Sep 22, 2022 · 3 comments
Open
2 of 7 tasks

@BeforeGroups ignores dependsOnGroups #2804

schroeca opened this issue Sep 22, 2022 · 3 comments

Comments

@schroeca
Copy link

TestNG 7.1.0

Note: only the latest version is supported

Expected behavior

The method annotated with @beforeGroups and all tests included in the defined group shall not be executed until all tests of the group on which the current group depends have finished. This includes also the @beforeGroups and @afterGroups method associated with the defined "depends on" group.

Actual behavior

The beforeGroups method and the tests included in group A are called after the beforeGroups method and the tests of group B. But group A is defined as "dependsOnGroup B".

Is the issue reproducible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

package playground.TestNgExperiments;

import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;

public class TestGroupDependsOnGroup {

    @BeforeGroups(groups = "A1", dependsOnGroups = "B1")
    public void beforeGroupA()
    {
        System.out.println("before group A");
    }

    @AfterGroups(groups ="A1")
    public void afterGroupA()
    {
        System.out.println("after group A");
    }

    @BeforeGroups(groups = "B1")
    public void beforeGroupB()
    {
        System.out.println("setup for Group B");
    }

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

    @Test(groups = "A1")
    public void GroupATest()
    {
        System.out.println("GroupDependsOnGroup.GroupATest");
    }

    @Test(groups = "A1")
    public void GroupATest1()
    {
        System.out.println("GroupDependsOnGroup.GroupATest1");
    }

    @Test(groups = "B1")
    public void GroupBTest()
    {
        System.out.println("GroupDependsOnGroup.GroupBTest");
    }
}

Intellij output

before group A
GroupDependsOnGroup.GroupATest
GroupDependsOnGroup.GroupATest1
after group A
setup for Group B
GroupDependsOnGroup.GroupBTest
GroupDependsOnGroup.NoGroup

===============================================
Default Suite
Total tests run: 4, Passes: 4, Failures: 0, Skips: 0
===============================================


Process finished with exit code 0
@krmahadevan
Copy link
Member

@schroeca - Do you know if this ever worked? I have been searching through the codebase to find any evidence of this working and so far its been a dead end. Couldn't even find a single test also that vets this out. So if you know in which version it worked, it would be good if you could please share that information so that I can dig in from there.

@schroeca
Copy link
Author

I got feedback from my team colleague that it was working in 7.0.4.

I have tested this by myself with various different versions for the past 3 weeks and it was never working.

I guess the test case my colleague used for testing was simply wrong.

Would it be possible to add the described "expected" behavior in one of your next releases?

@krmahadevan
Copy link
Member

@schroeca - Thanks for the quick turnaround. This issue is going to be a bit more complicated to fix, so please bear with the delay.

I will first try and cross compare the behaviour for @Test method. The behaviour for this also should be on par with how @Test with groups and dependsOnGroups behaves in terms of group selection, and it would also have all the behaviour of a configuration annotation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants