Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions testng-core-api/src/main/java/org/testng/ITestResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ default List<ITestNGMethod> getSkipCausedBy() {
*/
String id();

/**
* @return <code>true</code> if the current method (test|configuration) was executed by TestNG.
*/
default boolean wasExecuted() {
return !isNotRunning();
}

/**
* @return - <code>true</code> if the current test result is either {@link ITestResult#STARTED} or
* {@link ITestResult#CREATED}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,18 +285,23 @@ public void invokeConfigurations(ConfigMethodArguments arguments) {
arguments.getTestMethodResult());
testResult.setParameters(parameters);

runConfigurationListeners(testResult, arguments.getTestMethod(), true /* before */);

Object newInstance = computeInstance(arguments.getInstance(), inst, tm);
if (isConfigMethodEligibleForScrutiny(tm)) {
if (m_executedConfigMethods.add(arguments.getTestMethod())) {
runConfigurationListeners(testResult, arguments.getTestMethod(), true /* before */);
invokeConfigurationMethod(newInstance, tm, parameters, testResult);
}
} else {
runConfigurationListeners(testResult, arguments.getTestMethod(), true /* before */);
invokeConfigurationMethod(newInstance, tm, parameters, testResult);
}
copyAttributesFromNativelyInjectedTestResult(parameters, arguments.getTestMethodResult());
runConfigurationListeners(testResult, arguments.getTestMethod(), false /* after */);

if (testResult.wasExecuted()) {
// When it comes to "firstTimeOnly" configurations, some of them would NOT be run
// by TestNG. For those occurrences, DONOT run the listener.
runConfigurationListeners(testResult, arguments.getTestMethod(), false /* after */);
}
if (testResult.getStatus() == ITestResult.SKIP) {
Throwable t = testResult.getThrowable();
if (t != null) {
Expand Down