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

@DirtiesContext not honored in TestNG test suite #24685

Closed
C-Otto opened this issue Mar 12, 2020 · 2 comments
Closed

@DirtiesContext not honored in TestNG test suite #24685

C-Otto opened this issue Mar 12, 2020 · 2 comments
Assignees
Labels
in: test Issues in the test module status: invalid An issue that we don't feel is valid

Comments

@C-Otto
Copy link

C-Otto commented Mar 12, 2020

Affects: 5.2.4.RELEASE

<spring.version>5.2.4.RELEASE</spring.version>
<testng.version>7.1.0</testng.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>

To reproduce: https://github.com/C-Otto/dirtiescontext

I have a Spring, Maven, Java 8, TestNG setup where one test uses @DirtiesContext. In this VERY specific setup the test fails when I use mvn test. This seems to be related to the class names and the order in which tests are run.

Notice that the class AbstractClassSomeUnrelatedTest does not serve any purpose, but has the same name prefix as the abstract test class. Changing the name to something else fixes the problem.

Related to #8560?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 12, 2020
@sbrannen sbrannen added the in: test Issues in the test module label Mar 12, 2020
@sbrannen sbrannen changed the title @DirtiesContext not regarded (TestNG, test class hierarchy) @DirtiesContext not honored in TestNG test suite Mar 12, 2020
@sbrannen sbrannen self-assigned this Mar 12, 2020
@sbrannen
Copy link
Member

sbrannen commented Mar 12, 2020

Related to #8560?

Actually this is related to #10800, at least with respect to the explanation.

See the commit message for c0eafa9 for details.

In summary, your problem goes away if you annotate AbstractClassTestSupport with @Test(suiteName = "package a") (or some other unique suite name).

In light of that I am closing this issue.

As a side note, there is no need to declare maven-surefire-plugin as a standard test dependency since it is a plugin.

@sbrannen sbrannen added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 12, 2020
@C-Otto
Copy link
Author

C-Otto commented Mar 13, 2020

Thank you, that really helps. Tricky stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants