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?

Comment From: sbrannen

Related to #8560?

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

See the commit message for c0eafa9ea15676cf5f4c64b1c6edf2646771059e 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.

Comment From: C-Otto

Thank you, that really helps. Tricky stuff.