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

Add a test scenario for @BeforeGroups having a dependsOnGroups #2025

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions src/test/java/test/beforegroupdeps/BeforeGroupDependency.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package test.beforegroupdeps;

import static org.testng.Assert.*;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;

public class BeforeGroupDependency {
private boolean z1run = false;
private boolean z2run = false;
private boolean setupBrun = false;
private boolean a1run = false;
private boolean a2run = false;

@Test(groups="Z")
public void z1() {
System.out.println("z1");
assertFalse(setupBrun);
assertFalse(a1run);
assertFalse(a2run);
z1run = true;
}

@Test(groups="Z")
public void z2() {
System.out.println("z2");
assertFalse(setupBrun);
assertFalse(a1run);
assertFalse(a2run);
z2run = true;
}

@BeforeGroups(value="A", dependsOnGroups="Z")
public void setupA() {
System.out.println("setupB");
assertTrue(z1run);
assertTrue(z2run);
assertFalse(a1run);
assertFalse(a2run);
setupBrun = true;
}

@Test(groups="A")
public void a1() {
System.out.println("a1");
assertTrue(z1run);
assertTrue(z2run);
assertTrue(setupBrun);
a1run = true;
}

@Test(groups="A")
public void a2() {
System.out.println("a2");
assertTrue(z1run);
assertTrue(z2run);
assertTrue(setupBrun);
a2run = true;
}

}

1 change: 1 addition & 0 deletions src/test/resources/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
<class name="test.methodselection.MethodSelectionTest"/>
<class name="test.beforegroups.BeforeGroupsTest"/>
<class name="test.invocationcount.issue1719.IssueTest"/>
<class name="test.beforegroupdeps.BeforeGroupDependency"/>
</classes>
</test>

Expand Down