-
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
Duplicate Tests being added to XmlTests if XmlTest is used in the parameters of annotated methods #1994
Labels
Comments
krmahadevan
added a commit
to krmahadevan/testng
that referenced
this issue
Jan 1, 2019
Closes testng-team#1994 Currently as part of supporting native injection TestNG resorts to invoking the “clone()” method on the parameter being natively injected. This becomes a problem because XmlTest is the only internal TestNG object that implements the Cloneable interface wherein it resorts to something like a deep copy and adds the cloned instance to the XmlSuite. This causes a lot of phony XmlTest objects to be added up to the suite and causes issues as detailed in the bug. Fixed this by introducing a marker interface to indicate to TestNG to skip cloning and use the object as is. Annotated “XmlTest” with this annotation so that we dont clone xmltest but instead use it as is. Yes this will expose the XmlTest object, but its already exposed to the end user via various different means. So I guess we are ok here.
2 tasks
krmahadevan
added a commit
to krmahadevan/testng
that referenced
this issue
Jan 6, 2019
Closes testng-team#1994 Currently as part of supporting native injection TestNG resorts to invoking the “clone()” method on the parameter being natively injected. This becomes a problem because XmlTest is the only internal TestNG object that implements the Cloneable interface wherein it resorts to something like a deep copy and adds the cloned instance to the XmlSuite. This causes a lot of phony XmlTest objects to be added up to the suite and causes issues as detailed in the bug. Fixed this by introducing a marker interface to indicate to TestNG to skip cloning and use the object as is. Annotated “XmlTest” with this annotation so that we dont clone xmltest but instead use it as is. Yes this will expose the XmlTest object, but its already exposed to the end user via various different means. So I guess we are ok here.
2 tasks
krmahadevan
added a commit
to krmahadevan/testng
that referenced
this issue
Jan 8, 2019
Closes testng-team#1994 Currently as part of supporting native injection TestNG resorts to invoking the “clone()” method on the parameter being natively injected. This becomes a problem because XmlTest is the only internal TestNG object that implements the Cloneable interface wherein it resorts to something like a deep copy and adds the cloned instance to the XmlSuite. This causes a lot of phony XmlTest objects to be added up to the suite and causes issues as detailed in the bug. Fixed this by introducing a marker interface to indicate to TestNG to skip cloning and use the object as is. Annotated “XmlTest” with this annotation so that we dont clone xmltest but instead use it as is. Yes this will expose the XmlTest object, but its already exposed to the end user via various different means. So I guess we are ok here.
@krmahadevan I don't mean to rush but would be nice to know if there has been any update on this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TestNG Version
v7
Expected behavior
Current XmlTest is returned
Actual behavior
Duplicate test is added to XmlTest
Is the issue reproductible on runner?
Test case sample
For example, use the following
@BeforeTest
Run any sample suite with around 5 test cases
Now after the tests are executed, check the total number of tests using debugging mode in m_tests. It shows 8 tests which include duplicate tests being added which contain empty xmlClasses
These duplicate/ empty test cases are also causing random NullPointer Exceptions at the end of the tests. These NPEs are however not reproducible all the time.
Attached is a small zip file with a sample maven project. You can reproduce the duplicate tests issue by just running the
testng.xml
file from eclipse and checking them_tests
at theAfterSuite
methods by usingITestContext
like the below:Please let me know if any other info is needed
DuplicateTests.zip
The text was updated successfully, but these errors were encountered: