-
-
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.
Introduce EngineTestKit examples in the User Guide
Issue: #1621
- Loading branch information
Showing
3 changed files
with
130 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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; | ||
|
||
// tag::user_guide[] | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
import static org.junit.jupiter.api.Assumptions.assumeTrue; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ExampleTestCase { | ||
|
||
@Test | ||
@Disabled("for demonstration purposes") | ||
void skippedTest() { | ||
} | ||
|
||
@Test | ||
void succeedingTest() { | ||
} | ||
|
||
@Test | ||
void failingTest() { | ||
fail("a failing test"); | ||
} | ||
|
||
@Test | ||
void abortedTest() { | ||
assumeTrue("abc".contains("Z")); | ||
fail("test should have been aborted"); | ||
} | ||
|
||
} | ||
// end::user_guide[] |
48 changes: 48 additions & 0 deletions
48
documentation/src/test/java/example/testkit/EngineTestKitDemo.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,48 @@ | ||
/* | ||
* 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 example.ExampleTestCase; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.platform.testkit.engine.EngineTestKit; | ||
|
||
class EngineTestKitDemo { | ||
|
||
@Test | ||
void verifyJupiterContainerStats() { | ||
EngineTestKit | ||
.engine("junit-jupiter") // <1> | ||
.selectors(selectClass(ExampleTestCase.class)) // <2> | ||
.execute() // <3> | ||
.containers() // <4> | ||
.assertStatistics(stats -> stats.started(2).succeeded(2)); // <5> | ||
} | ||
|
||
@Test | ||
void verifyJupiterTestStats() { | ||
EngineTestKit | ||
.engine("junit-jupiter") // <1> | ||
.selectors(selectClass(ExampleTestCase.class)) // <2> | ||
.execute() // <3> | ||
.tests() // <6> | ||
.assertStatistics(stats -> | ||
stats.skipped(1).started(3).succeeded(1).aborted(1).failed(1)); // <7> | ||
} | ||
|
||
} | ||
// end::user_guide[] | ||
// @formatter:on |