Search in sources :

Example 16 with Events

use of org.junit.platform.testkit.engine.Events in project spring-framework by spring-projects.

the class TimedTransactionalSpringExtensionTests method springTransactionsWorkWithJUnitJupiterTimeouts.

@Test
void springTransactionsWorkWithJUnitJupiterTimeouts() {
    Events events = EngineTestKit.engine("junit-jupiter").selectors(selectClass(TestCase.class)).execute().testEvents().assertStatistics(stats -> stats.started(4).succeeded(2).failed(2));
    events.failed().assertThatEvents().haveExactly(2, event(test("WithExceededJUnitJupiterTimeout"), finishedWithFailure(instanceOf(TimeoutException.class), message(msg -> msg.endsWith("timed out after 10 milliseconds")))));
}
Also used : Events(org.junit.platform.testkit.engine.Events) EventConditions.event(org.junit.platform.testkit.engine.EventConditions.event) DiscoverySelectors.selectClass(org.junit.platform.engine.discovery.DiscoverySelectors.selectClass) TimeoutException(java.util.concurrent.TimeoutException) EventConditions.finishedWithFailure(org.junit.platform.testkit.engine.EventConditions.finishedWithFailure) TestExecutionResultConditions.message(org.junit.platform.testkit.engine.TestExecutionResultConditions.message) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) Configuration(org.springframework.context.annotation.Configuration) SpringJUnitConfig(org.springframework.test.context.junit.jupiter.SpringJUnitConfig) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) TransactionAssert.assertThatTransaction(org.springframework.test.transaction.TransactionAssert.assertThatTransaction) Propagation(org.springframework.transaction.annotation.Propagation) TestExecutionResultConditions.instanceOf(org.junit.platform.testkit.engine.TestExecutionResultConditions.instanceOf) DataSourceTransactionManager(org.springframework.jdbc.datasource.DataSourceTransactionManager) EngineTestKit(org.junit.platform.testkit.engine.EngineTestKit) DataSource(javax.sql.DataSource) EmbeddedDatabaseBuilder(org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder) EventConditions.test(org.junit.platform.testkit.engine.EventConditions.test) Bean(org.springframework.context.annotation.Bean) FailingTestCase(org.springframework.test.context.junit.jupiter.FailingTestCase) Timeout(org.junit.jupiter.api.Timeout) Transactional(org.springframework.transaction.annotation.Transactional) Events(org.junit.platform.testkit.engine.Events) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.jupiter.api.Test)

Aggregations

Events (org.junit.platform.testkit.engine.Events)16 Test (org.junit.jupiter.api.Test)15 DiscoverySelectors.selectClass (org.junit.platform.engine.discovery.DiscoverySelectors.selectClass)9 EngineTestKit (org.junit.platform.testkit.engine.EngineTestKit)9 EventConditions.event (org.junit.platform.testkit.engine.EventConditions.event)9 EventConditions.finishedWithFailure (org.junit.platform.testkit.engine.EventConditions.finishedWithFailure)9 TestExecutionResultConditions.instanceOf (org.junit.platform.testkit.engine.TestExecutionResultConditions.instanceOf)9 TestExecutionResultConditions.message (org.junit.platform.testkit.engine.TestExecutionResultConditions.message)9 ENGINE_ID (org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor.ENGINE_ID)8 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)4 ExtensionConfigurationException (org.junit.jupiter.api.extension.ExtensionConfigurationException)4 ExtensionContextException (org.junit.jupiter.api.extension.ExtensionContextException)4 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)3 DbmsExtensionMixImpermanent (org.neo4j.test.extension.dbms.DbmsExtensionMixImpermanent)3 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)2 Nested (org.junit.jupiter.api.Nested)2 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)2 LifecycleAdapter (org.neo4j.kernel.lifecycle.LifecycleAdapter)2 DbmsExtensionCheckCallbackSignature (org.neo4j.test.extension.dbms.DbmsExtensionCheckCallbackSignature)2 DbmsExtensionEnforceAnnotations (org.neo4j.test.extension.dbms.DbmsExtensionEnforceAnnotations)2