-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document how to verify ALL events with the EngineTestKit in User Guide
Issue: #1621
- Loading branch information
Showing
3 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
documentation/src/test/java/example/testkit/EngineTestKitAllEventsDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2015-2018 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package example.testkit; | ||
|
||
// @formatter:off | ||
// tag::user_guide[] | ||
|
||
import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass; | ||
import static org.junit.platform.testkit.engine.EventConditions.abortedWithReason; | ||
import static org.junit.platform.testkit.engine.EventConditions.container; | ||
import static org.junit.platform.testkit.engine.EventConditions.engine; | ||
import static org.junit.platform.testkit.engine.EventConditions.event; | ||
import static org.junit.platform.testkit.engine.EventConditions.finishedSuccessfully; | ||
import static org.junit.platform.testkit.engine.EventConditions.finishedWithFailure; | ||
import static org.junit.platform.testkit.engine.EventConditions.skippedWithReason; | ||
import static org.junit.platform.testkit.engine.EventConditions.started; | ||
import static org.junit.platform.testkit.engine.EventConditions.test; | ||
import static org.junit.platform.testkit.engine.TestExecutionResultConditions.isA; | ||
import static org.junit.platform.testkit.engine.TestExecutionResultConditions.message; | ||
|
||
import example.ExampleTestCase; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.platform.testkit.engine.EngineTestKit; | ||
import org.opentest4j.TestAbortedException; | ||
|
||
class EngineTestKitAllEventsDemo { | ||
|
||
@Test | ||
void verifyAllJupiterEvents() { | ||
EngineTestKit.engine("junit-jupiter") // <1> | ||
.selectors(selectClass(ExampleTestCase.class)) // <2> | ||
.execute() // <3> | ||
.all() // <4> | ||
.debug() // <5> | ||
.assertEventsMatchExactly( // <6> | ||
event(engine(), started()), | ||
event(container(ExampleTestCase.class), started()), | ||
event(test("skippedTest"), skippedWithReason("for demonstration purposes")), | ||
event(test("succeedingTest"), started()), | ||
event(test("succeedingTest"), finishedSuccessfully()), | ||
event(test("abortedTest"), started()), | ||
event(test("abortedTest"), | ||
abortedWithReason(isA(TestAbortedException.class), | ||
message(m -> m.contains("abc does not contain Z")))), | ||
event(test("failingTest"), started()), | ||
event(test("failingTest"), | ||
finishedWithFailure(isA(ArithmeticException.class), message("/ by zero"))), | ||
event(container(ExampleTestCase.class), finishedSuccessfully()), | ||
event(engine(), finishedSuccessfully())); | ||
} | ||
|
||
} | ||
// end::user_guide[] | ||
// @formatter:on |