-
Notifications
You must be signed in to change notification settings - Fork 1k
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 only called if group is specified explicitly #118
Comments
This still is an issue with the latest build of TestnG 6.9.10 with @BeforeGroups not inheriting group sets. A more detailed break down is found here. |
Here's my observations ( This is as of TestNG
The below sample will reproduce the problem import org.testng.Assert;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
@Test(groups = "group1")
public class Group1Test {
private Object testObject;
@BeforeGroups
public void setUpGroup() {
testObject = new Object();
}
public void test1() {
Assert.assertNotNull(testObject, "@BeforeGroups not invoked if nothing explicitly specified");
}
} testng xml <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Default suite">
<test verbose="0" name="group1 included">
<groups>
<run>
<include name="group1"/>
</run>
</groups>
<classes>
<class name="testng_issue_118.Group1Test"/>
</classes>
</test>
</suite>
|
Closes testng-team#118 As part of fixing this issue, flipped the attribute “inheritGroups” to “false”. This was done because this attribute has not worked till now and with the bug fix, it will start breaking compatibility for everyone, because now @BeforeGroups will inherit any class level groups specified. By inverting this attribute to false, backward compatibility is retained and it also gives a chance to the users to turn it on explicitly when needed.
@krmahadevan Doesn't this break the @BeforeClass and @ AfterClass logic? I have a class annotated with @test(groups = { "some_group"}) which contains a method annotated with @BeforeClass and with the change here
create becomes true, while previously it was false. This broke our build because a circular dependency was found due to this change. I short a method with the following configuration
would be considered AfterGroups method configuration when the class is annotated with @ Test (groups{"blabla"}). The same goes for an AfterClass. |
@petar-lichev - do you have a sample project to share so that I can use it to reproduce the issue that you are experiencing? |
@krmahadevan Yes, I pushed it here - https://github.com/petar-lichev/sample-project master branch uses testng version 7.4.0. When you run the SampleTest you get:
Which seems to come from getAfterGroupsConfigurationMethods and the change in findConfiguration
returns true, because of the group configuration of the class level annotation of SampleTest. Which itself results in some cyclic dependency between I've also pushed the branch 6.14.3(test passes there) to showcase the different behaviour in_getAfterGroupsConfigurationMethods_ . Any idea if that is expected and it was the intended change in behaviour? |
The latest released versions are:
Can you please help upgrade to |
@krmahadevan Same error. testMethodFinder.getAfterGroupsConfigurationMethods(m_testClass) throws the Exception about a circular dependency between the methods. `The following methods have cyclic dependencies:
|
Will take a look. Thanks. |
Thanks. These below are my only other observations.
Basically with the adding of the shouldCreateBeforeAfterGroup method in the switch case, the behaviour changed, because of the @ Test(groups={"some_group"}) in SampleTest and the following now returns true:
|
@krmahadevan Hi, did you manage to take a look? |
There are 3 Testclasses each belonging to a different group. Each Test has a method annotated with @BeforeGroups. Though this method is actually only in one case called before the group is executed.
groups=
.@Test
annotation of the containing class.alwaysRun=true
specifiedThere is a maven project that reflects the described behaviour.
The text was updated successfully, but these errors were encountered: