Skip to content

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

@luengoa17

Description

@luengoa17

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
	}

}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions