You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run the test (IntelliJ or mvn test) and note it fails. Then apply any solution from the comments and observe the test passes:
packagecom.example; // 1. to make the test PASS change to `org.example`importorg.testng.annotations.BeforeClass;
importorg.testng.annotations.Test;
importstaticorg.testng.Assert.assertNotNull;
publicclassMyTestextendsMyBaseTest {
@BeforeClasspublicvoidbeforeClass() {
assertNotNull(dependency); // fails here
}
@Testpublicvoidtest() {
}
}
abstractclassMyBaseTestimplementsMyInterface { // 2. alternatively, to make the test PASS remove `implements MyInterface`protectedObjectdependency;
publicvoidsetDependency(Objectdependency) {
}
@BeforeClasspublicvoidsetupDependency() {
dependency = newObject();
}
@BeforeClass(dependsOnMethods = "setupDependency")
publicvoidsetupAdditionalDependency_() { // 3. alternatively, to make the test PASS remove `_` from the method name
}
}
interfaceMyInterface {
voidsetDependency(Objectdependency);
defaultObjectgetDependency() { // 4. alternatively, to make the test PASS remove this methodreturnnull;
}
}
Something that may direct you to the solution:
Debug code at Graph:130 (at the end of topologicalSort()) and observe the object's state:
m_strictlySortedNodes = {ArrayList@2283} size = 3
0 = {ConfigurationMethod@2293} "MyTest.beforeClass()[pri:0, instance:null]" // I believe it should not be here, as the list should contain only independent (top level?) methods
1 = {ConfigurationMethod@2294} "MyTest.setupDependency()[pri:0, instance:null]"
2 = {ConfigurationMethod@2295} "MyTest.setupAdditionalDependency_()[pri:0, instance:null]"
The text was updated successfully, but these errors were encountered:
ptomaszek
added a commit
to ptomaszek/testng-pt-playground
that referenced
this issue
Oct 28, 2023
⁸### TestNG Version
7.8.0
onJDK 11 Temurin
(Liniux and Windows)maven-surefire-plugin:3.1.2
aspectjweaver:1.9.20.1
Or check out the source code: https://github.com/ptomaszek/testng-pt-playground/tree/feature/testng-7.8.0-unexpected-failure
Expected behavior
Test passes
Actual behavior
Test fails
Is the issue reproducible on runner?
Test case sample
Run the test (IntelliJ or
mvn test
) and note it fails. Then apply any solution from the comments and observe the test passes:Something that may direct you to the solution:
Debug code at
Graph:130
(at the end oftopologicalSort()
) and observe the object's state:when PASS, you'll see:
when FAIL, you'll see
The text was updated successfully, but these errors were encountered: