Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,11 @@ private static Stream<Throwable> throwables(Set<ITestResult> results) {

private static Throwable chain(Stream<Throwable> failures) {
Iterator<Throwable> iterator = failures.iterator();
Throwable throwable = iterator.next();
iterator.forEachRemaining(throwable::addSuppressed);
Throwable throwable = null;
if (iterator.hasNext()) {
throwable = iterator.next();
iterator.forEachRemaining(throwable::addSuppressed);
}
return throwable;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,24 @@
package org.junit.support.testng.engine;

import static java.util.function.Predicate.isEqual;
import static org.assertj.core.api.Assertions.allOf;
import static org.junit.platform.commons.util.FunctionUtils.where;
import static org.junit.platform.engine.TestExecutionResult.Status.ABORTED;
import static org.junit.platform.testkit.engine.Event.byTestDescriptor;
import static org.junit.platform.testkit.engine.EventConditions.container;
import static org.junit.platform.testkit.engine.EventConditions.displayName;
import static org.junit.platform.testkit.engine.EventConditions.event;
import static org.junit.platform.testkit.engine.EventConditions.finished;
import static org.junit.platform.testkit.engine.EventConditions.uniqueIdSubstring;
import static org.junit.platform.testkit.engine.TestExecutionResultConditions.status;

import java.nio.file.Path;
import java.util.Optional;

import org.assertj.core.api.Condition;
import org.junit.jupiter.api.io.TempDir;
import org.junit.platform.engine.TestDescriptor;
import org.junit.platform.engine.TestExecutionResult;
import org.junit.platform.testkit.engine.EngineTestKit;
import org.junit.platform.testkit.engine.Event;

Expand All @@ -48,4 +54,13 @@ static Condition<Event> legacyReportingName(String legacyReportingName) {
byTestDescriptor(where(TestDescriptor::getLegacyReportingName, isEqual(legacyReportingName))),
"descriptor with legacy reporting name '%s'", legacyReportingName);
}

static Condition<Event> abortedWithoutReason() {
return finished(allOf(status(ABORTED), emptyThrowable()));
}

static Condition<TestExecutionResult> emptyThrowable() {
return new Condition<>(where(TestExecutionResult::getThrowable, Optional::isEmpty), "throwable is empty");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void reportsFailureFromEarlyEngineLevelConfigurationMethodAsAborted(Class<?> tes
event(testClass(testClass), started()), //
event(test("method:test()"), started()), //
event(test("method:test()"), abortedWithReason(message("boom"))), //
event(testClass(testClass), finishedSuccessfully()), //
event(testClass(testClass), abortedWithoutReason()), //
event(engine(), finishedWithFailure(message("boom"))));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

package example.configuration.methods;

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

Expand All @@ -20,6 +21,11 @@ public void beforeSuite() {
throw new AssertionError("boom");
}

@BeforeMethod
public void beforeMethod() {
// never called
}

@Test
public void test() {
// never called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

package example.configuration.methods;

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

Expand All @@ -20,6 +21,11 @@ public void beforeTest() {
throw new AssertionError("boom");
}

@BeforeMethod
public void beforeMethod() {
// never called
}

@Test
public void test() {
// never called
Expand Down