|
1 | | -# Resource-Based Testing in JUnit 5 |
| 1 | +# Milestone 7 Demo |
2 | 2 |
|
3 | | -This project provides a sample [JUnit Test Engine](https://docs.junit.org/current/user-guide/#test-engines) that uses resource files to |
4 | | -define tests that can be run with JUnit 5. |
| 3 | +This project demonstrates running non-class-based tests via the Tooling API. The demo consists of the following projects: |
| 4 | +- `engine`: contains a JUnit Test engine demonstrating resource-based test execution. |
| 5 | +- `demo-m7`: a test project that defines tests in the `tests.xml` using the test engine. |
| 6 | +- `demo-m7-client`: a sample Tooling API client that invokes the `customTest` task on the `demo-m7` project and renders the progress events on the console. |
5 | 7 |
|
6 | | -This project contains an included build in `/sample-consumer`. |
| 8 | +Run the demo project using `./gradlew :demo-m7-client:run -q` from the root of this repository. |
7 | 9 |
|
8 | | -Run that project to demo using the plugin in a Gradle build with: `executeTests`. |
| 10 | +## Details |
| 11 | + |
| 12 | +The test engine defined in `engine` project is slightly modified to exhibit the following behavior. For each test definition it: |
| 13 | +- provides some output on stdout for each test, |
| 14 | +- will fail tests with names containing the 'fail' substring, |
| 15 | +- will skip tests with names containing the 'skip' substring, |
| 16 | +- will publish metadata for tests with names containing the 'publishMetadata' substring, |
| 17 | +- will publish a file entry for tests with names containing the 'publishFile' substring, and |
| 18 | +- succeeds the remaining tests. |
| 19 | + |
| 20 | +The `demo-m7` project defines a `customtest` task that uses the test engine and exercise all the above behaviors. |
| 21 | + |
| 22 | +Tooling API client is defined in the `M7ToolingClient` class. It connects to the `demo-m7` project and invokes the `customTest` task. |
| 23 | +The client listens to the following progress event operation types: TEST, TEST_OUTPUT and TEST_METADATA. |
| 24 | + |
| 25 | +The rendered output should look similar to the following: |
| 26 | + |
| 27 | +``` |
| 28 | +------------------------------------------------ |
| 29 | +Running resource-based tests via the Tooling API |
| 30 | +------------------------------------------------ |
| 31 | +START Gradle Test Run :demo-m7:customTest |
| 32 | + START Gradle Test Executor 27 |
| 33 | + START Test tests.xml : failingTest (file=/Users/donat/Development/git/gradle/sample-rbt-engine/demo-m7/src/customTest/definitions/tests.xml) |
| 34 | + OUTPUT StdOut: Test engine fails tests with names containing the 'fail' substring Test [file=tests.xml, name=failingTest] |
| 35 | + FAILURE Test tests.xml : failingTest (file=/Users/donat/Development/git/gradle/sample-rbt-engine/demo-m7/src/customTest/definitions/tests.xml) (reason: Test failed because its name contains the 'fail' substring) |
| 36 | + START Test tests.xml : skippedTest (file=/Users/donat/Development/git/gradle/sample-rbt-engine/demo-m7/src/customTest/definitions/tests.xml) |
| 37 | + OUTPUT StdOut: Test engine skips tests with names containing the 'skip' substring Test [file=tests.xml, name=skippedTest] |
| 38 | + SKIPPED Test tests.xml : skippedTest (file=/Users/donat/Development/git/gradle/sample-rbt-engine/demo-m7/src/customTest/definitions/tests.xml) |
| 39 | + START Test tests.xml : publishMetadataTest (file=/Users/donat/Development/git/gradle/sample-rbt-engine/demo-m7/src/customTest/definitions/tests.xml) |
| 40 | + OUTPUT StdOut: Test engine publishes some metadata for tests with names containing the 'publishMetadata' substring Test [file=tests.xml, name=publishMetadataTest] |
| 41 | + METADATA Entry:{non-class-based-testing=check} |
| 42 | + SUCCESS Test tests.xml : publishMetadataTest (file=/Users/donat/Development/git/gradle/sample-rbt-engine/demo-m7/src/customTest/definitions/tests.xml) |
| 43 | + START Test tests.xml : publishFileTest (file=/Users/donat/Development/git/gradle/sample-rbt-engine/demo-m7/src/customTest/definitions/tests.xml) |
| 44 | + OUTPUT StdOut: Test engine publishes a file entry for tests with names containing the 'publishFile' substring Test [file=tests.xml, name=publishFileTest] |
| 45 | + METADATA File: /var/folders/6v/j9zhh5fs00b_bbr2f35_7s7m0000gq/T/tests.txt type: text/plain |
| 46 | + SUCCESS Test tests.xml : publishFileTest (file=/Users/donat/Development/git/gradle/sample-rbt-engine/demo-m7/src/customTest/definitions/tests.xml) |
| 47 | + START Test tests.xml : passingTest (file=/Users/donat/Development/git/gradle/sample-rbt-engine/demo-m7/src/customTest/definitions/tests.xml) |
| 48 | + SUCCESS Test tests.xml : passingTest (file=/Users/donat/Development/git/gradle/sample-rbt-engine/demo-m7/src/customTest/definitions/tests.xml) |
| 49 | + FAILURE Gradle Test Executor 27 |
| 50 | +FAILURE Gradle Test Run :demo-m7:customTest |
| 51 | +``` |
| 52 | + |
| 53 | +The indentations represent the event hierarchy. It demonstrates that the Tooling API client can successfully execute non-class-based tests, and it emits the same events and data for |
| 54 | +- Test started/finished |
| 55 | +- The test results: successful, failed, skipped |
| 56 | +- The test metadata (including ReportEntry and FileEntry), and |
| 57 | +- Test output |
| 58 | + |
| 59 | +NOTE: this demo uses a snapshot version of Gradle 9.4.0 that includes the non-class-based testing feature. |
| 60 | +We'll update the demo once a milestone or a release version is available with the feature. |
0 commit comments