use of org.junit.jupiter.api.fixtures.TrackLogRecords in project junit5 by junit-team.
the class JupiterEngineExecutionContextTests method closeAttemptExceptionWillBeThrownDownTheCallStack.
@Test
@TrackLogRecords
void closeAttemptExceptionWillBeThrownDownTheCallStack(LogRecordListener logRecordListener) throws Exception {
ExtensionContext failingExtensionContext = mock(ExtensionContext.class, withSettings().extraInterfaces(AutoCloseable.class));
Exception expectedException = new Exception("test message");
doThrow(expectedException).when(((AutoCloseable) failingExtensionContext)).close();
JupiterEngineExecutionContext newContext = //
originalContext.extend().withExtensionContext(//
failingExtensionContext).build();
Exception actualException = assertThrows(Exception.class, newContext::close);
assertSame(expectedException, actualException);
//
assertThat(logRecordListener.stream(JupiterEngineExecutionContext.class, Level.SEVERE)).extracting(//
LogRecord::getMessage).containsOnly("Caught exception while closing extension context: " + failingExtensionContext);
}
use of org.junit.jupiter.api.fixtures.TrackLogRecords in project junit5 by junit-team.
the class DefaultLauncherTests method thirdPartyEngineUsingReservedEngineIdPrefixEmitsWarning.
@Test
@TrackLogRecords
void thirdPartyEngineUsingReservedEngineIdPrefixEmitsWarning(LogRecordListener listener) {
var id = "junit-using-reserved-prefix";
createLauncher(new TestEngineStub(id));
//
assertThat(listener.stream(EngineIdValidator.class, Level.WARNING).map(LogRecord::getMessage)).containsExactly("Third-party TestEngine implementations are forbidden to use the reserved 'junit-' prefix for their ID: '" + id + "'");
}
Aggregations