Search in sources :

Example 11 with Events

use of org.junit.platform.testkit.engine.Events in project neo4j by neo4j.

the class SuppressOutputExtensionTest method shouldThrowExceptionOnMissingResourceLock.

@Test
void shouldThrowExceptionOnMissingResourceLock() {
    Events testEvents = EngineTestKit.engine(ENGINE_ID).selectors(selectClass(SuppressOutputExtensionIncorrectUsage.class)).execute().testEvents();
    testEvents.assertThatEvents().haveExactly(1, event(finishedWithFailure(instanceOf(IllegalStateException.class), message(message -> message.contains("SuppressOutputExtension requires `@ResourceLock( Resources.SYSTEM_OUT )` annotation.")))));
}
Also used : Events(org.junit.platform.testkit.engine.Events) ENGINE_ID(org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor.ENGINE_ID) EventConditions.event(org.junit.platform.testkit.engine.EventConditions.event) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DiscoverySelectors.selectClass(org.junit.platform.engine.discovery.DiscoverySelectors.selectClass) EventConditions.finishedWithFailure(org.junit.platform.testkit.engine.EventConditions.finishedWithFailure) ResourceLock(org.junit.jupiter.api.parallel.ResourceLock) TestExecutionResultConditions.message(org.junit.platform.testkit.engine.TestExecutionResultConditions.message) Nested(org.junit.jupiter.api.Nested) Test(org.junit.jupiter.api.Test) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) TestExecutionResultConditions.instanceOf(org.junit.platform.testkit.engine.TestExecutionResultConditions.instanceOf) EngineTestKit(org.junit.platform.testkit.engine.EngineTestKit) Resources(org.junit.jupiter.api.parallel.Resources) SuppressOutput(org.neo4j.test.rule.SuppressOutput) Events(org.junit.platform.testkit.engine.Events) Test(org.junit.jupiter.api.Test)

Example 12 with Events

use of org.junit.platform.testkit.engine.Events in project neo4j by neo4j.

the class ThreadLeakageGuardExtensionTest method threadLeakageTest.

@Test
void threadLeakageTest() throws InterruptedException {
    Events testEvents = EngineTestKit.engine(ENGINE_ID).selectors(selectClass(IncorrectThreadLeakage.class)).execute().allEvents();
    testEvents.assertThatEvents().haveExactly(1, event(finishedWithFailure(instanceOf(ExtensionContextException.class), message(message -> message.contains("1 leaked thread(s) detected")))));
    IncorrectThreadLeakage.cleanUp();
}
Also used : Test(org.junit.jupiter.api.Test) Events(org.junit.platform.testkit.engine.Events) ENGINE_ID(org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor.ENGINE_ID) EventConditions.event(org.junit.platform.testkit.engine.EventConditions.event) ExtensionContextException(org.junit.jupiter.api.extension.ExtensionContextException) TestExecutionResultConditions.instanceOf(org.junit.platform.testkit.engine.TestExecutionResultConditions.instanceOf) DisabledIfSystemProperty(org.junit.jupiter.api.condition.DisabledIfSystemProperty) EngineTestKit(org.junit.platform.testkit.engine.EngineTestKit) DiscoverySelectors.selectClass(org.junit.platform.engine.discovery.DiscoverySelectors.selectClass) EventConditions.finishedWithFailure(org.junit.platform.testkit.engine.EventConditions.finishedWithFailure) TestExecutionResultConditions.message(org.junit.platform.testkit.engine.TestExecutionResultConditions.message) Events(org.junit.platform.testkit.engine.Events) ExtensionContextException(org.junit.jupiter.api.extension.ExtensionContextException) Test(org.junit.jupiter.api.Test)

Example 13 with Events

use of org.junit.platform.testkit.engine.Events in project neo4j by neo4j.

the class JUnitUsageGuardExtensionTest method validTestUsage.

@Test
void validTestUsage() {
    Events testEvents = executeTest(ValidUsage.class);
    assertEquals(0, testEvents.failed().count());
}
Also used : Events(org.junit.platform.testkit.engine.Events) Test(org.junit.jupiter.api.Test)

Example 14 with Events

use of org.junit.platform.testkit.engine.Events in project neo4j by neo4j.

the class JUnitUsageGuardExtensionTest method detectMixtureOfDifferentTests.

@Test
void detectMixtureOfDifferentTests() {
    Events testEvents = executeTest(MixOfDifferentJUnits.class);
    verifyFailureMessage(testEvents, "Detected Junit 4 classes: [org.junit.Test]");
}
Also used : Events(org.junit.platform.testkit.engine.Events) Test(org.junit.jupiter.api.Test)

Example 15 with Events

use of org.junit.platform.testkit.engine.Events in project neo4j by neo4j.

the class JUnitUsageGuardExtensionTest method deleteOldRuleAndNewTest.

@Test
void deleteOldRuleAndNewTest() {
    Events testEvents = executeTest(MixRuleAndNewJUnit.class);
    verifyFailureMessage(testEvents, "Detected Junit 4 classes: [org.junit.Rule, org.junit.rules.ExpectedException]");
}
Also used : Events(org.junit.platform.testkit.engine.Events) 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