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

ITestResult injected at @AfterMethod incorrect when a configuration method failed #3006

Closed
3 of 7 tasks
luengoa17 opened this issue Nov 17, 2023 · 0 comments · Fixed by #3007
Closed
3 of 7 tasks

ITestResult injected at @AfterMethod incorrect when a configuration method failed #3006

luengoa17 opened this issue Nov 17, 2023 · 0 comments · Fixed by #3007

Comments

@luengoa17
Copy link

luengoa17 commented Nov 17, 2023

TestNG Version

v7.8.0

Expected behavior

When a configuration method (method decorated with @BeforeMethod) fails. The method decorated with @AfterMehtod(alwayRun=true) recives an ITestResult object with status SKIPPED (3) and the information about the configuration methods that failed.

Actual behavior

When a configuration method (method decorated with @BeforeMethod) fails. The method decorated with @AfterMehtod(alwayRun=true) recives an ITestResult object with status CREATED (-1) and no information about the skip reason.

Is the issue reproducible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

package playground;

import static org.testng.Assert.assertTrue;

import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class BugTest {
	
	@BeforeMethod
	public void beforeMethod() {
		throw new RuntimeException("Exception to simulate configuration error");
	}
	
	@Test
	public void test() {
		assertTrue(true);
	}
	
	@AfterMethod(alwaysRun = true)
	public void afterMethod(ITestResult testResult) {
		System.out.println(testResult.getStatus()); // -1
	}

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants