├── .github
└── workflows
│ ├── ci.yml
│ ├── release.yml
│ └── snapshot.yml
├── .gitignore
├── LICENSE.txt
├── README.md
├── pom.xml
└── src
├── main
├── java
│ └── org
│ │ └── pitest
│ │ └── junit5
│ │ ├── JUnit5Configuration.java
│ │ ├── JUnit5TestPluginFactory.java
│ │ ├── JUnit5TestSuiteFinder.java
│ │ ├── JUnit5TestUnit.java
│ │ └── JUnit5TestUnitFinder.java
└── resources
│ └── META-INF
│ └── services
│ └── org.pitest.testapi.TestPluginFactory
└── test
├── groovy
└── org
│ └── pitest
│ └── junit5
│ └── repository
│ ├── TestSpec.groovy
│ ├── TestSpecWithAbortingFeature.groovy
│ ├── TestSpecWithCleanupSpec.groovy
│ ├── TestSpecWithDataDrivenFeature.groovy
│ ├── TestSpecWithFailingCleanupSpec.groovy
│ ├── TestSpecWithFailingFeature.groovy
│ ├── TestSpecWithFailingSetupSpec.groovy
│ ├── TestSpecWithIncludedFeature.groovy
│ ├── TestSpecWithInheritedFeature.groovy
│ ├── TestSpecWithMixedPassAndFail.groovy
│ ├── TestSpecWithMultiplePassingFeatures.groovy
│ ├── TestSpecWithSetupSpec.groovy
│ ├── TestSpecWithSimpleFeature.groovy
│ ├── TestSpecWithTags.groovy
│ └── TestSpecWithoutFeatures.groovy
├── java
└── org
│ └── pitest
│ └── junit5
│ ├── JUnit5TestUnitFinderTest.java
│ ├── JUnit5TestUnitTest.java
│ ├── cucumber
│ ├── Glue.java
│ └── RunCucumberTest.java
│ └── repository
│ ├── AbstractTestClass.java
│ ├── InterfaceTestClass.java
│ ├── ParameterizedNoExplicitSource.java
│ ├── TestClass.java
│ ├── TestClassWithAbortingTest.java
│ ├── TestClassWithAfterAll.java
│ ├── TestClassWithBeforeAll.java
│ ├── TestClassWithFailingAfterAll.java
│ ├── TestClassWithFailingBeforeAll.java
│ ├── TestClassWithFailingTest.java
│ ├── TestClassWithIncludedTestMethod.java
│ ├── TestClassWithInheritedTestMethod.java
│ ├── TestClassWithMixedPassAndFail.java
│ ├── TestClassWithMultiplePassingTests.java
│ ├── TestClassWithNestedAnnotationAndNestedTestAnnotation.java
│ ├── TestClassWithNestedAnnotationAndNestedTestFactoryAnnotation.java
│ ├── TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation.java
│ ├── TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation.java
│ ├── TestClassWithNestedClassWithNestedAnnotationAndNestedTestAnnotation.java
│ ├── TestClassWithNestedClassWithNestedAnnotationAndNestedTestFactoryAnnotation.java
│ ├── TestClassWithNestedClassWithoutAnnotations.java
│ ├── TestClassWithParameterizedTestAnnotation.java
│ ├── TestClassWithRepeatedTestAnnotation.java
│ ├── TestClassWithTags.java
│ ├── TestClassWithTestAnnotation.java
│ ├── TestClassWithTestFactoryAnnotation.java
│ ├── TestClassWithTestTemplateAnnotation.java
│ └── TestClassWithoutAnnotations.java
└── resources
└── org
└── pitest
└── junit5
└── cucumber
└── pitest-junit5-cucumber.feature
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | push:
4 | branches:
5 | - 'master'
6 | pull_request:
7 | branches-ignore:
8 | - 'release'
9 | jobs:
10 | supported-jdk:
11 | name: ${{ matrix.title }}
12 | continue-on-error: false
13 | strategy:
14 | fail-fast: false
15 | matrix:
16 | include:
17 | - title: "JDK 11"
18 | java: 11
19 | - title: "JDK 16"
20 | java: "16-ea"
21 | runs-on: ubuntu-latest
22 | steps:
23 | - name: 'Checkout from Git'
24 | uses: actions/checkout@v3
25 | - name: 'Set up JDK ${{ matrix.java }}'
26 | uses: actions/setup-java@v4
27 | with:
28 | java-version: ${{ matrix.java }}
29 | distribution: adopt
30 | - name: 'Display JDK version'
31 | run: java -version
32 | - name: Cache local Maven repository
33 | uses: actions/cache@v3
34 | with:
35 | path: ~/.m2/repository
36 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
37 | restore-keys: ${{ runner.os }}-maven-
38 | - name: 'Test'
39 | run: mvn -B verify
40 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 | on:
3 | push:
4 | branches:
5 | - release/**
6 | jobs:
7 | release:
8 | runs-on: ubuntu-latest
9 | # sonatype nexus sometimes hangs
10 | timeout-minutes: 20
11 | steps:
12 | - name: Extract branch name
13 | shell: bash
14 | run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})"
15 | id: extract_branch
16 | - name: Install gpg secret key
17 | run: |
18 | cat <(echo -e "${{ secrets.GPG_SECRET_KEY }}") | gpg --batch --import
19 | gpg --list-secret-keys --keyid-format LONG
20 | - name: Checkout project
21 | uses: actions/checkout@v3
22 | - name: Cache local Maven repository
23 | uses: actions/cache@v3
24 | with:
25 | path: ~/.m2/repository
26 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
27 | restore-keys: ${{ runner.os }}-maven-
28 | - name: Setup Java JDK
29 | uses: actions/setup-java@v4
30 | with:
31 | java-version: 8
32 | distribution: adopt
33 | server-id: central
34 | server-username: MAVEN_USERNAME
35 | server-password: MAVEN_PASSWORD
36 | - name: Configure Git user
37 | run: |
38 | git config user.email "actions@github.com"
39 | git config user.name "GitHub Actions"
40 | - name: Publish JAR
41 | run: mvn -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE}} -B -Prelease deploy scm:tag -Drevision=${{ steps.extract_branch.outputs.branch }} -DskipTests=true
42 | env:
43 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44 | MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
45 | MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
46 |
--------------------------------------------------------------------------------
/.github/workflows/snapshot.yml:
--------------------------------------------------------------------------------
1 | name: Deploy snapshot
2 | on:
3 | push:
4 | branches:
5 | - master
6 | jobs:
7 | snapshot:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - name: Checkout project
11 | uses: actions/checkout@v3
12 | - name: Cache local Maven repository
13 | uses: actions/cache@v3
14 | with:
15 | path: ~/.m2/repository
16 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
17 | restore-keys: ${{ runner.os }}-maven-
18 | - name: Setup Java JDK
19 | uses: actions/setup-java@v4
20 | with:
21 | java-version: 8
22 | distribution: adopt
23 | server-id: central
24 | server-username: MAVEN_USERNAME
25 | server-password: MAVEN_PASSWORD
26 | - name: Publish JARs
27 | run: mvn -B deploy -DskipTests=true
28 | env:
29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 | MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
31 | MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Maven ###
2 | dependency-reduced-pom.xml
3 | /target/
4 | .flattened-pom.xml
5 |
6 | ### STS ###
7 | .apt_generated
8 | .classpath
9 | .factorypath
10 | .project
11 | .settings
12 | .springBeans
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | nbproject/private/
22 | build/
23 | nbbuild/
24 | dist/
25 | nbdist/
26 | .nb-gradle/
27 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JUnit 5 Plugin
2 |
3 | Adds support to pitest for JUnit 5 platform test engines, e.g. Jupiter, Cucumber, or Spock.
4 |
5 | ## Versions
6 |
7 | [](https://central.sonatype.com/artifact/org.pitest/pitest-junit5-plugin)
8 |
9 | ## 1.2.3
10 |
11 | Adds support for Quarkus 3.22.x and above.
12 |
13 | Requires pitest 1.19.4 or above.
14 |
15 | ## Older Versions
16 |
17 | Releases 1.2.1 and 1.2.2 requires pitest 1.15.2 or above.
18 |
19 | Release 1.2.0 requires pitest 1.14.0 or above.
20 |
21 | When used with the pitest-maven plugin, or version 1.15.0 of the gradle plugin, it will automatically work with JUnit platform 1.5.0 to 1.10.0-M1 (and probably above).
22 |
23 | When used with earlier versions of the pitest gradle plugin a dependency must be added to a compatible version of junit-platform-launcher. Depending on how the gradle project is configured the must be added wither a scope of either pitest, or a testImplementation.
24 |
25 | Older versions of the plugin must be matched to both the pitest and junit version in use as below.
26 |
27 | * 1.1.2 requires pitest 1.9.0 or above and JUnit Platform 1.9.2 (Jupiter 5.9.2)
28 | * 1.1.1 requires pitest 1.9.0 or above and JUnit Platform 1.9.1 (Jupiter 5.9.1)
29 | * 1.1.0 requires pitest 1.9.0 or above and JUnit Platform 1.9.1 (Jupiter 5.9.1)
30 | * 1.0.0 requires pitest 1.9.0 or above and JUnit Platform 1.8.x (Jupiter 5.8.0)
31 | * 0.16 requires pitest 1.4.0 or above and JUnit Platform 1.8.x (Jupiter 5.8.0)
32 | * 0.15 requires pitest 1.4.0 or above and JUnit Platform 1.8.x (Jupiter 5.8.0)
33 | * 0.5-0.14 requires pitest 1.4.0 or above and JUnit Platform 1.7.x (Jupiter 5.7.x)
34 | * 0.4 requires pitest 1.3.2 or above
35 | * 0.3 requires pitest 1.3.0 or 1.3.1
36 | * 0.2 requires pitest 1.2.5
37 |
38 | ## Usage
39 |
40 | The plugin has been built against the versions of JUnit platform noted above - you may encounter issues if you use it with a different version.
41 |
42 | To activate the plugin it must be placed on the classpath of the pitest tool (**not** on the classpath of the project being mutated).
43 |
44 | ### Maven
45 |
46 | ```xml
47 |
48 |
49 | org.pitest
50 | pitest-maven
51 | 1.18.2
52 |
53 |
54 | org.pitest
55 | pitest-junit5-plugin
56 | 1.2.2
57 |
58 |
59 |
60 |
61 | ```
62 | For Pitest configuration options, have a look at http://pitest.org/quickstart/maven/.
63 |
64 | ### Gradle
65 |
66 | ```
67 | plugins {
68 | id 'java'
69 | id 'info.solidsoft.pitest' version '1.15.0'
70 | }
71 |
72 | pitest {
73 | //adds dependency to org.pitest:pitest-junit5-plugin and sets "testPlugin" to "junit5"
74 | junit5PluginVersion = '1.2.2'
75 | pitestVersion = '1.18.2'
76 | // ...
77 | }
78 | ```
79 |
80 | See [gradle-pitest-plugin documentation](https://github.com/szpak/gradle-pitest-plugin#pit-test-plugins-support) for more configuration options.
81 |
82 | ## Release Notes
83 |
84 | ### 1.2.2
85 |
86 | * #109 Set platform-launcher dependency to provided
87 |
88 | The pitest maven and gradle plugins now automatically resolve the correct version of platform launcher at
89 | runtime. The built against version of platform-launcher was however being included as a transative dependency sometimes
90 | causing a conflict at runtime.
91 |
92 | ### 1.2.1
93 |
94 | * #103 Report errors and failures during scan stage
95 |
96 | ### 1.1.1
97 |
98 | * #73 Automatically disable parallel mode
99 |
100 | ### 0.16
101 |
102 | * #64 Errors in `BeforeAll` methods do not register
103 |
104 | ## About
105 |
106 | Plugin originally created by @tobiasstadler.
107 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | org.pitest
6 | pitest-junit5-plugin
7 | ${revision}
8 |
9 | pitest-junit5-plugin
10 | http://pitest.org
11 | JUnit 5 plugin for pitest
12 |
13 | jar
14 |
15 |
16 |
17 | 1.0.0-SNAPSHOT
18 |
19 | UTF-8
20 | 1.8
21 | 1.8
22 | 3.14.0
23 | 1.9.2
24 | 5.9.2
25 | 2.7.6
26 | 1.15.2
27 | 5.0.0
28 | 2.3-groovy-4.0
29 | 4.0.11
30 |
31 |
32 |
33 | https://github.com/pitest/pitest-junit5-plugin
34 |
35 | scm:git:https://github.com/pitest/pitest-junit5-plugin.git
36 | HEAD
37 |
38 |
39 |
40 | https://github.com/hcoles/pitest/issues
41 | GitHub
42 |
43 |
44 |
45 | henry
46 | Henry Coles
47 | henry@pitest.org
48 |
49 |
50 |
51 |
52 | The Apache Software License, Version 2.0
53 | http://www.apache.org/licenses/LICENSE-2.0.txt
54 | repo
55 |
56 |
57 |
58 |
59 |
60 | release
61 |
62 |
63 | performRelease
64 | true
65 |
66 |
67 |
68 |
69 |
70 | org.sonatype.central
71 | central-publishing-maven-plugin
72 | 0.7.0
73 | true
74 |
75 | central
76 | true
77 |
78 |
79 |
80 | org.apache.maven.plugins
81 | maven-javadoc-plugin
82 | 3.2.0
83 |
84 |
85 | javadoc
86 |
87 | jar
88 |
89 |
90 |
91 |
92 | false
93 | -Xdoclint:none
94 |
95 |
96 |
97 | org.apache.maven.plugins
98 | maven-gpg-plugin
99 | 1.6
100 |
101 |
102 | sign-artifacts
103 | verify
104 |
105 | sign
106 |
107 |
108 |
109 |
110 |
111 | --pinentry-mode
112 | loopback
113 |
114 |
115 |
116 |
117 | maven-scm-plugin
118 | 1.11.2
119 |
120 | ${project.version}
121 |
122 |
123 |
124 | org.apache.maven.plugins
125 | maven-source-plugin
126 | 3.0.1
127 |
128 |
129 | attach-sources
130 |
131 | jar
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 | org.spockframework
145 | spock-bom
146 | ${spock.version}
147 | pom
148 | import
149 |
150 |
151 | org.apache.groovy
152 | groovy-bom
153 | ${groovy.version}
154 | pom
155 | import
156 |
157 |
158 |
159 |
160 |
161 |
162 | org.pitest
163 | pitest
164 | ${pitest.version}
165 | provided
166 |
167 |
168 | org.junit.platform
169 | junit-platform-launcher
170 | ${junit.platform.version}
171 | provided
172 |
173 |
174 | org.junit.jupiter
175 | junit-jupiter
176 | ${junit.version}
177 | test
178 |
179 |
180 | org.assertj
181 | assertj-core
182 | ${assertj.version}
183 | test
184 |
185 |
186 | io.cucumber
187 | cucumber-junit-platform-engine
188 | ${cucumber.version}
189 | test
190 |
191 |
192 | io.cucumber
193 | cucumber-java8
194 | ${cucumber.version}
195 | test
196 |
197 |
198 | org.spockframework
199 | spock-core
200 | test
201 |
202 |
203 |
204 |
205 |
206 |
207 | maven-compiler-plugin
208 | 3.8.1
209 |
210 | true
211 |
212 |
213 |
214 | org.codehaus.gmavenplus
215 | gmavenplus-plugin
216 | 2.1.0
217 |
218 |
219 |
220 | generateTestStubs
221 | compileTests
222 | removeTestStubs
223 |
224 |
225 |
226 |
227 |
228 | org.apache.maven.plugins
229 | maven-surefire-plugin
230 | 2.22.2
231 |
232 |
233 | **/TestClass*
234 | **/TestSpec*
235 |
236 |
237 |
238 |
239 | org.jacoco
240 | jacoco-maven-plugin
241 | 0.8.11
242 |
243 |
244 |
245 | prepare-agent
246 | report
247 |
248 |
249 |
250 |
251 |
252 | org.codehaus.mojo
253 | flatten-maven-plugin
254 | 1.2.5
255 |
256 | true
257 | resolveCiFriendliesOnly
258 |
259 |
260 |
261 | flatten
262 | package
263 |
264 | flatten
265 |
266 |
267 |
268 | flatten.clean
269 | clean
270 |
271 | clean
272 |
273 |
274 |
275 |
276 |
277 | org.apache.maven.plugins
278 | maven-jar-plugin
279 | 3.2.0
280 |
281 |
282 |
283 | true
284 |
285 |
286 | ${project.groupId}
287 | ${project.artifactId}
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 | central
299 | https://central.sonatype.com/repository/maven-snapshots/
300 |
301 |
302 |
303 |
--------------------------------------------------------------------------------
/src/main/java/org/pitest/junit5/JUnit5Configuration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5;
16 |
17 | import java.util.Collection;
18 | import java.util.Optional;
19 |
20 | import org.pitest.help.PitHelpError;
21 | import org.pitest.testapi.Configuration;
22 | import org.pitest.testapi.TestGroupConfig;
23 | import org.pitest.testapi.TestSuiteFinder;
24 | import org.pitest.testapi.TestUnitFinder;
25 |
26 | /**
27 | *
28 | * @author Tobias Stadler
29 | */
30 | public class JUnit5Configuration implements Configuration {
31 |
32 | private final TestGroupConfig testGroupConfig;
33 |
34 | private final Collection includedTestMethods;
35 |
36 | public JUnit5Configuration(TestGroupConfig testGroupConfig, Collection includedTestMethods) {
37 | this.testGroupConfig = testGroupConfig;
38 | this.includedTestMethods = includedTestMethods;
39 | }
40 |
41 | @Override
42 | public TestUnitFinder testUnitFinder() {
43 | return new JUnit5TestUnitFinder(testGroupConfig, includedTestMethods);
44 | }
45 |
46 | @Override
47 | public TestSuiteFinder testSuiteFinder() {
48 | return new JUnit5TestSuiteFinder();
49 | }
50 |
51 | @Override
52 | public Optional verifyEnvironment() {
53 | return Optional.empty();
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/org/pitest/junit5/JUnit5TestPluginFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5;
16 |
17 | import java.util.Collection;
18 | import org.pitest.classinfo.ClassByteArraySource;
19 | import org.pitest.testapi.Configuration;
20 | import org.pitest.testapi.TestGroupConfig;
21 | import org.pitest.testapi.TestPluginFactory;
22 |
23 | /**
24 | *
25 | * @author Tobias Stadler
26 | */
27 | public class JUnit5TestPluginFactory implements TestPluginFactory {
28 |
29 | @Override
30 | public Configuration createTestFrameworkConfiguration(TestGroupConfig config,
31 | ClassByteArraySource source,
32 | Collection excludedRunners,
33 | Collection includedTestMethods) {
34 | System.setProperty("junit.jupiter.execution.parallel.enabled", "false");
35 | return new JUnit5Configuration(config, includedTestMethods);
36 | }
37 |
38 | @Override
39 | public String description() {
40 | return "JUnit 5 test framework support";
41 | }
42 |
43 | @Override
44 | public String name() {
45 | return "junit5";
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/pitest/junit5/JUnit5TestSuiteFinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package org.pitest.junit5;
7 |
8 | import java.util.Collections;
9 | import java.util.List;
10 | import org.pitest.testapi.TestSuiteFinder;
11 |
12 | /**
13 | *
14 | * @author Tobias Stadler
15 | */
16 | public class JUnit5TestSuiteFinder implements TestSuiteFinder {
17 |
18 | @Override
19 | public List> apply(Class> a) {
20 | return Collections.emptyList();
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/pitest/junit5/JUnit5TestUnit.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5;
16 |
17 | import java.util.Optional;
18 |
19 | import org.junit.platform.engine.TestExecutionResult;
20 | import org.junit.platform.engine.discovery.DiscoverySelectors;
21 | import org.junit.platform.launcher.Launcher;
22 | import org.junit.platform.launcher.LauncherDiscoveryRequest;
23 | import org.junit.platform.launcher.TestExecutionListener;
24 | import org.junit.platform.launcher.TestIdentifier;
25 | import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
26 | import org.junit.platform.launcher.core.LauncherFactory;
27 | import org.pitest.testapi.AbstractTestUnit;
28 | import org.pitest.testapi.Description;
29 | import org.pitest.testapi.ExecutedInDiscovery;
30 | import org.pitest.testapi.ResultCollector;
31 |
32 | /**
33 | *
34 | * @author Tobias Stadler
35 | */
36 | public class JUnit5TestUnit extends AbstractTestUnit implements ExecutedInDiscovery {
37 |
38 | private final Class> testClass;
39 |
40 | private final TestIdentifier testIdentifier;
41 |
42 | public JUnit5TestUnit(Class> testClass, TestIdentifier testIdentifier) {
43 | super(new Description(testIdentifier.getUniqueId(), testClass));
44 | this.testClass = testClass;
45 | this.testIdentifier = testIdentifier;
46 | }
47 |
48 | @Override
49 | public void execute(ResultCollector resultCollector) {
50 | Launcher launcher = LauncherFactory.create();
51 | LauncherDiscoveryRequest launcherDiscoveryRequest = LauncherDiscoveryRequestBuilder
52 | .request()
53 | .selectors(DiscoverySelectors.selectUniqueId(testIdentifier.getUniqueId()))
54 | .build();
55 |
56 | launcher.registerTestExecutionListeners(new TestExecutionListener() {
57 | @Override
58 | public void executionSkipped(TestIdentifier testIdentifier, String reason) {
59 | if (testIdentifier.isTest()) {
60 | resultCollector.notifySkipped(new Description(testIdentifier.getUniqueId(), testClass));
61 | }
62 | }
63 |
64 | @Override
65 | public void executionStarted(TestIdentifier testIdentifier) {
66 | if (testIdentifier.isTest()) {
67 | resultCollector.notifyStart(new Description(testIdentifier.getUniqueId(), testClass));
68 | }
69 | }
70 |
71 | @Override
72 | public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
73 | Optional throwable = testExecutionResult.getThrowable();
74 | if (testIdentifier.isTest()) {
75 | if (TestExecutionResult.Status.ABORTED == testExecutionResult.getStatus()) {
76 | // abort treated as success
77 | // see: https://junit.org/junit5/docs/5.0.0/api/org/junit/jupiter/api/Assumptions.html
78 | resultCollector.notifyEnd(new Description(testIdentifier.getUniqueId(), testClass));
79 | } else if (throwable.isPresent()) {
80 | resultCollector.notifyEnd(new Description(testIdentifier.getUniqueId(), testClass), throwable.get());
81 | } else {
82 | resultCollector.notifyEnd(new Description(testIdentifier.getUniqueId(), testClass));
83 | }
84 | } else {
85 | // Classes with failing BeforeAll methods identify as containers, not tests.
86 | if (throwable.isPresent()) {
87 | resultCollector.notifyEnd(new Description(testIdentifier.getUniqueId(), testClass), throwable.get());
88 | }
89 | }
90 | }
91 |
92 | });
93 | launcher.execute(launcherDiscoveryRequest);
94 | }
95 |
96 |
97 | @Override
98 | public String toString() {
99 | return "JUnit5TestUnit [uniqueId=" + testIdentifier.getUniqueId()
100 | + ", displayName=" + testIdentifier.getDisplayName() + "]";
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/src/main/java/org/pitest/junit5/JUnit5TestUnitFinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5;
16 |
17 | import java.util.ArrayList;
18 | import java.util.Collection;
19 | import java.util.List;
20 | import java.util.stream.Collectors;
21 |
22 | import static java.util.Collections.emptyList;
23 | import static java.util.Collections.synchronizedList;
24 | import static java.util.Collections.unmodifiableList;
25 | import static java.util.stream.Collectors.toList;
26 |
27 | import org.junit.platform.commons.PreconditionViolationException;
28 | import org.junit.platform.engine.DiscoverySelector;
29 | import org.junit.platform.engine.Filter;
30 | import org.junit.platform.engine.TestExecutionResult;
31 | import org.junit.platform.engine.discovery.DiscoverySelectors;
32 | import org.junit.platform.engine.support.descriptor.MethodSource;
33 | import org.junit.platform.launcher.Launcher;
34 | import org.junit.platform.launcher.TagFilter;
35 | import org.junit.platform.launcher.TestExecutionListener;
36 | import org.junit.platform.launcher.TestIdentifier;
37 | import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
38 | import org.junit.platform.launcher.core.LauncherFactory;
39 | import org.pitest.testapi.Description;
40 | import org.pitest.testapi.TestGroupConfig;
41 | import org.pitest.testapi.TestUnit;
42 | import org.pitest.testapi.TestUnitExecutionListener;
43 | import org.pitest.testapi.TestUnitFinder;
44 |
45 | /**
46 | *
47 | * @author Tobias Stadler
48 | */
49 | public class JUnit5TestUnitFinder implements TestUnitFinder {
50 |
51 | private final TestGroupConfig testGroupConfig;
52 |
53 | private final Collection includedTestMethods;
54 |
55 | private final Launcher launcher;
56 |
57 | public JUnit5TestUnitFinder(TestGroupConfig testGroupConfig, Collection includedTestMethods) {
58 | this.testGroupConfig = testGroupConfig;
59 | this.includedTestMethods = includedTestMethods;
60 | this.launcher = LauncherFactory.create();
61 | }
62 |
63 | @Override
64 | public List findTestUnits(Class> clazz, TestUnitExecutionListener executionListener) {
65 | if(clazz.getEnclosingClass() != null) {
66 | return emptyList();
67 | }
68 |
69 | List filters = new ArrayList<>(2);
70 | try {
71 | List excludedGroups = filterEmptyStrings(testGroupConfig.getExcludedGroups());
72 | if(!excludedGroups.isEmpty()) {
73 | filters.add(TagFilter.excludeTags(excludedGroups));
74 | }
75 |
76 | List includedGroups = filterEmptyStrings(testGroupConfig.getIncludedGroups());
77 | if(!includedGroups.isEmpty()) {
78 | filters.add(TagFilter.includeTags(includedGroups));
79 | }
80 | } catch(PreconditionViolationException e) {
81 | throw new IllegalArgumentException("Error creating tag filter", e);
82 | }
83 |
84 | TestIdentifierListener listener = new TestIdentifierListener(clazz, executionListener);
85 |
86 | // Although we have a class instance to examine, some junit 5 extensions (well Quarkus, but maybe also others)
87 | // switch the classloader during discover. Must therefore drop back to a name string so classloading
88 | // matches normal execution.
89 | DiscoverySelector selector = DiscoverySelectors.selectClass(clazz.getName());
90 |
91 | launcher.execute(LauncherDiscoveryRequestBuilder
92 | .request()
93 | .selectors(selector)
94 | .filters(filters.toArray(new Filter[filters.size()]))
95 | .build(), listener);
96 |
97 | return listener.getIdentifiers()
98 | .stream()
99 | .map(testIdentifier -> new JUnit5TestUnit(clazz, testIdentifier))
100 | .collect(toList());
101 | }
102 |
103 | private List filterEmptyStrings(List testGroupConfig) {
104 | return testGroupConfig.stream()
105 | .filter(group -> !group.isEmpty())
106 | .collect(Collectors.toList());
107 | }
108 |
109 | private class TestIdentifierListener implements TestExecutionListener {
110 | private final Class> testClass;
111 | private final TestUnitExecutionListener l;
112 | private final List identifiers = synchronizedList(new ArrayList<>());
113 |
114 | public TestIdentifierListener(Class> testClass, TestUnitExecutionListener l) {
115 | this.testClass = testClass;
116 | this.l = l;
117 | }
118 |
119 | List getIdentifiers() {
120 | return unmodifiableList(new ArrayList<>(identifiers));
121 | }
122 |
123 | @Override
124 | public void executionStarted(TestIdentifier testIdentifier) {
125 | if (testIdentifier.isTest()) {
126 | // filter out testMethods
127 | if (includedTestMethods != null && !includedTestMethods.isEmpty()
128 | && testIdentifier.getSource().isPresent()
129 | && testIdentifier.getSource().get() instanceof MethodSource
130 | && !includedTestMethods.contains(((MethodSource)testIdentifier.getSource().get()).getMethodName())) {
131 | return;
132 | }
133 | l.executionStarted(new Description(testIdentifier.getUniqueId(), testClass));
134 | identifiers.add(testIdentifier);
135 | }
136 | }
137 |
138 |
139 | @Override
140 | public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
141 | // Classes with failing BeforeAlls never start execution and identify as 'containers' not 'tests'
142 | if (testExecutionResult.getStatus() == TestExecutionResult.Status.FAILED) {
143 | if (!identifiers.contains(testIdentifier)) {
144 | identifiers.add(testIdentifier);
145 | }
146 | l.executionFinished(new Description(testIdentifier.getUniqueId(), testClass)
147 | , false, testExecutionResult.getThrowable().orElse(null));
148 | } else if (testIdentifier.isTest()) {
149 | l.executionFinished(new Description(testIdentifier.getUniqueId(), testClass)
150 | , true);
151 | }
152 | }
153 |
154 | }
155 |
156 | }
157 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/services/org.pitest.testapi.TestPluginFactory:
--------------------------------------------------------------------------------
1 | org.pitest.junit5.JUnit5TestPluginFactory
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Specification
20 |
21 | class TestSpec extends Specification {
22 | def test() {
23 | expect:
24 | true
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithAbortingFeature.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import org.opentest4j.TestAbortedException
20 | import spock.lang.IgnoreIf
21 | import spock.lang.Specification
22 |
23 | class TestSpecWithAbortingFeature extends Specification {
24 | @IgnoreIf({ data.ignore })
25 | def test() {
26 | expect:
27 | false
28 |
29 | where:
30 | ignore = true
31 | }
32 |
33 | def test2() {
34 | expect:
35 | throw new TestAbortedException()
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithCleanupSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Specification
20 |
21 | class TestSpecWithCleanupSpec extends Specification {
22 | def cleanupSpec() {
23 | }
24 |
25 | def aTest() {
26 | expect:
27 | true
28 | }
29 |
30 | def anotherTest() {
31 | expect:
32 | true
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithDataDrivenFeature.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Specification
20 |
21 | class TestSpecWithDataDrivenFeature extends Specification {
22 | def test() {
23 | expect:
24 | true
25 |
26 | where:
27 | i = 1
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithFailingCleanupSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Specification
20 |
21 | class TestSpecWithFailingCleanupSpec extends Specification {
22 | def cleanupSpec() {
23 | assert false
24 | }
25 |
26 | def aTest() {
27 | expect:
28 | true
29 | }
30 |
31 | def anotherTest() {
32 | expect:
33 | true
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithFailingFeature.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Specification
20 |
21 | class TestSpecWithFailingFeature extends Specification {
22 | def test() {
23 | expect:
24 | false
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithFailingSetupSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Specification
20 |
21 | class TestSpecWithFailingSetupSpec extends Specification {
22 | def setupSpec() {
23 | assert false
24 | }
25 |
26 | def aTest() {
27 | expect:
28 | true
29 | }
30 |
31 | def anotherTest() {
32 | expect:
33 | true
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithIncludedFeature.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Specification
20 |
21 | class TestSpecWithIncludedFeature extends Specification {
22 | def test() {
23 | expect:
24 | true
25 | }
26 |
27 | def included() {
28 | expect:
29 | true
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithInheritedFeature.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | class TestSpecWithInheritedFeature extends TestSpec {
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithMixedPassAndFail.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Specification
20 |
21 | class TestSpecWithMixedPassAndFail extends Specification {
22 | def passingTest() {
23 | expect:
24 | true
25 | }
26 |
27 | def passingTest2() {
28 | expect:
29 | true
30 | }
31 |
32 | def failingTest() {
33 | expect:
34 | false
35 | }
36 |
37 | def erroringTest() {
38 | expect:
39 | throw new RuntimeException()
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithMultiplePassingFeatures.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Specification
20 |
21 | class TestSpecWithMultiplePassingFeatures extends Specification {
22 | def testOne() {
23 | expect:
24 | true
25 | }
26 |
27 | def testTwo() {
28 | expect:
29 | true
30 | }
31 |
32 | def testThree() {
33 | expect:
34 | true
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithSetupSpec.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Shared
20 | import spock.lang.Specification
21 |
22 | class TestSpecWithSetupSpec extends Specification {
23 | @Shared
24 | def fail = true
25 |
26 | def setupSpec() {
27 | fail = false
28 | }
29 |
30 | def aTest() {
31 | expect:
32 | !fail
33 | }
34 |
35 | def anotherTest() {
36 | expect:
37 | !fail
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithSimpleFeature.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Specification
20 |
21 | class TestSpecWithSimpleFeature extends Specification {
22 | def test() {
23 | expect:
24 | true
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithTags.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Specification
20 | import spock.lang.Tag
21 |
22 | class TestSpecWithTags extends Specification {
23 | def testWithoutTag() {
24 | expect:
25 | true
26 | }
27 |
28 | @Tag("foo")
29 | def testWithTag() {
30 | expect:
31 | true
32 | }
33 |
34 | @Tag("included")
35 | def testWithIncludedTag() {
36 | expect:
37 | true
38 | }
39 |
40 | @Tag("excluded")
41 | def testWithExcludedTag() {
42 | expect:
43 | true
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/groovy/org/pitest/junit5/repository/TestSpecWithoutFeatures.groovy:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 Björn Kautler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pitest.junit5.repository
18 |
19 | import spock.lang.Specification
20 |
21 | class TestSpecWithoutFeatures extends Specification {
22 | def test() {
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/JUnit5TestUnitFinderTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5;
16 |
17 | import static java.util.Collections.emptyList;
18 | import static java.util.Collections.singletonList;
19 | import static org.assertj.core.api.Assertions.assertThat;
20 |
21 | import org.junit.jupiter.api.Test;
22 | import org.opentest4j.AssertionFailedError;
23 | import org.pitest.junit5.cucumber.RunCucumberTest;
24 | import org.pitest.junit5.repository.AbstractTestClass;
25 | import org.pitest.junit5.repository.InterfaceTestClass;
26 | import org.pitest.junit5.repository.ParameterizedNoExplicitSource;
27 | import org.pitest.junit5.repository.TestClassWithAbortingTest;
28 | import org.pitest.junit5.repository.TestClassWithAfterAll;
29 | import org.pitest.junit5.repository.TestClassWithBeforeAll;
30 | import org.pitest.junit5.repository.TestClassWithFailingAfterAll;
31 | import org.pitest.junit5.repository.TestClassWithFailingBeforeAll;
32 | import org.pitest.junit5.repository.TestClassWithFailingTest;
33 | import org.pitest.junit5.repository.TestClassWithIncludedTestMethod;
34 | import org.pitest.junit5.repository.TestClassWithInheritedTestMethod;
35 | import org.pitest.junit5.repository.TestClassWithMixedPassAndFail;
36 | import org.pitest.junit5.repository.TestClassWithMultiplePassingTests;
37 | import org.pitest.junit5.repository.TestClassWithNestedAnnotationAndNestedTestAnnotation;
38 | import org.pitest.junit5.repository.TestClassWithNestedAnnotationAndNestedTestFactoryAnnotation;
39 | import org.pitest.junit5.repository.TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation;
40 | import org.pitest.junit5.repository.TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation;
41 | import org.pitest.junit5.repository.TestClassWithNestedClassWithNestedAnnotationAndNestedTestAnnotation;
42 | import org.pitest.junit5.repository.TestClassWithNestedClassWithNestedAnnotationAndNestedTestFactoryAnnotation;
43 | import org.pitest.junit5.repository.TestClassWithNestedClassWithoutAnnotations;
44 | import org.pitest.junit5.repository.TestClassWithParameterizedTestAnnotation;
45 | import org.pitest.junit5.repository.TestClassWithRepeatedTestAnnotation;
46 | import org.pitest.junit5.repository.TestClassWithTags;
47 | import org.pitest.junit5.repository.TestClassWithTestAnnotation;
48 | import org.pitest.junit5.repository.TestClassWithTestFactoryAnnotation;
49 | import org.pitest.junit5.repository.TestClassWithTestTemplateAnnotation;
50 | import org.pitest.junit5.repository.TestClassWithoutAnnotations;
51 | import org.pitest.junit5.repository.TestSpecWithCleanupSpec;
52 | import org.pitest.junit5.repository.TestSpecWithAbortingFeature;
53 | import org.pitest.junit5.repository.TestSpecWithDataDrivenFeature;
54 | import org.pitest.junit5.repository.TestSpecWithFailingCleanupSpec;
55 | import org.pitest.junit5.repository.TestSpecWithFailingFeature;
56 | import org.pitest.junit5.repository.TestSpecWithFailingSetupSpec;
57 | import org.pitest.junit5.repository.TestSpecWithIncludedFeature;
58 | import org.pitest.junit5.repository.TestSpecWithInheritedFeature;
59 | import org.pitest.junit5.repository.TestSpecWithMixedPassAndFail;
60 | import org.pitest.junit5.repository.TestSpecWithMultiplePassingFeatures;
61 | import org.pitest.junit5.repository.TestSpecWithSetupSpec;
62 | import org.pitest.junit5.repository.TestSpecWithSimpleFeature;
63 | import org.pitest.junit5.repository.TestSpecWithTags;
64 | import org.pitest.junit5.repository.TestSpecWithoutFeatures;
65 | import org.pitest.testapi.Description;
66 | import org.pitest.testapi.ExecutedInDiscovery;
67 | import org.pitest.testapi.NullExecutionListener;
68 | import org.pitest.testapi.TestGroupConfig;
69 | import org.pitest.testapi.TestUnit;
70 | import org.pitest.testapi.TestUnitExecutionListener;
71 | import org.spockframework.runtime.ConditionNotSatisfiedError;
72 |
73 | import java.util.ArrayList;
74 | import java.util.List;
75 | import java.util.function.Predicate;
76 | import java.util.stream.Collectors;
77 |
78 | /**
79 | * @author Tobias Stadler
80 | */
81 | class JUnit5TestUnitFinderTest {
82 |
83 | @Test
84 | void findsAndRunsBasicJupiterTests() {
85 | findsAndRunsNTests(1, TestClassWithTestAnnotation.class);
86 | }
87 |
88 | @Test
89 | void findsAndRunsBasicSpockTests() {
90 | findsAndRunsNTests(1, TestSpecWithSimpleFeature.class);
91 | }
92 |
93 | @Test
94 | void findsAndRunsBasicJupiterTestsWhenMultiplePresent() {
95 | findsAndRunsNTests(3, TestClassWithMultiplePassingTests.class);
96 | }
97 |
98 | @Test
99 | void findsAndRunsBasicSpockTestsWhenMultiplePresent() {
100 | findsAndRunsNTests(3, TestSpecWithMultiplePassingFeatures.class);
101 | }
102 |
103 | @Test
104 | void descriptionsOfTestsRunDuringDiscoveryMatchThoseOfDiscoveredTests() {
105 | JUnit5TestUnitFinder underTest = basicConfig();
106 | List runInDiscovery = run(underTest, TestClassWithMultiplePassingTests.class).started;
107 | List discovered = underTest.findTestUnits(TestClassWithMultiplePassingTests.class, new NullExecutionListener())
108 | .stream()
109 | .map(tu -> tu.getDescription())
110 | .collect(Collectors.toList());
111 |
112 | assertThat(runInDiscovery).containsExactlyInAnyOrderElementsOf(discovered);
113 | }
114 |
115 | @Test
116 | void descriptionsOfTestsRunDuringDiscoveryMatchThoseOfDiscoveredSpockTests() {
117 | JUnit5TestUnitFinder underTest = basicConfig();
118 | List runInDiscovery = run(underTest, TestSpecWithMultiplePassingFeatures.class).started;
119 | List discovered = underTest.findTestUnits(TestSpecWithMultiplePassingFeatures.class, new NullExecutionListener())
120 | .stream()
121 | .map(tu -> tu.getDescription())
122 | .collect(Collectors.toList());
123 |
124 | assertThat(runInDiscovery).containsExactlyInAnyOrderElementsOf(discovered);
125 | }
126 |
127 | @Test
128 | void discoveredTestsAreMarkedAsExecuted() {
129 | JUnit5TestUnitFinder underTest = basicConfig();
130 | List discovered = underTest.findTestUnits(TestClassWithMultiplePassingTests.class,
131 | new NullExecutionListener());
132 |
133 | assertThat(discovered).allMatch(tu -> tu instanceof ExecutedInDiscovery);
134 | }
135 |
136 | @Test
137 | void discoveredSpockTestsAreMarkedAsExecuted() {
138 | JUnit5TestUnitFinder underTest = basicConfig();
139 | List discovered = underTest.findTestUnits(TestSpecWithMultiplePassingFeatures.class,
140 | new NullExecutionListener());
141 |
142 | assertThat(discovered).allMatch(tu -> tu instanceof ExecutedInDiscovery);
143 | }
144 |
145 | @Test
146 | void detectsFailingTests() {
147 | findsAndRunsNTests(1, TestClassWithFailingTest.class);
148 | nTestsFails(1, TestClassWithFailingTest.class);
149 | }
150 |
151 | @Test
152 | void detectsFailingSpockTests() {
153 | findsAndRunsNTests(1, TestSpecWithFailingFeature.class);
154 | nTestsFails(1, TestSpecWithFailingFeature.class);
155 | errorIsRecorded(t -> t instanceof ConditionNotSatisfiedError, TestSpecWithFailingFeature.class);
156 | }
157 |
158 | @Test
159 | void detectsErroringTestsWhenPassingTestsPresent() {
160 | nTestsPass(2, TestClassWithMixedPassAndFail.class);
161 | nTestsFails(2, TestClassWithMixedPassAndFail.class);
162 | errorIsRecorded(t -> t instanceof RuntimeException, TestClassWithMixedPassAndFail.class);
163 | }
164 |
165 | @Test
166 | void detectsErroringSpockTestsWhenPassingTestsPresent() {
167 | nTestsPass(2, TestSpecWithMixedPassAndFail.class);
168 | nTestsFails(2, TestSpecWithMixedPassAndFail.class);
169 | }
170 |
171 | @Test
172 | void findsAndRunsParameterizedTests() {
173 | findsAndRunsNTests(4, TestClassWithParameterizedTestAnnotation.class);
174 | }
175 |
176 | @Test
177 | void findsAndRunsParameterizedTestsWithoutExplicitMethodSource() {
178 | findsAndRunsNTests(2, ParameterizedNoExplicitSource.class);
179 | }
180 |
181 |
182 | @Test
183 | void findsAndRunsTestsWithRepeatedATestAnnotation() {
184 | findsAndRunsNTests(1, TestClassWithRepeatedTestAnnotation.class);
185 | }
186 |
187 | @Test
188 | void findsAndRunsTestsFromTestFactoryAnnotation() {
189 | findsAndRunsNTests(1, TestClassWithTestFactoryAnnotation.class);
190 | }
191 |
192 | @Test
193 | void findsAndRunsTestsFromTestTemplateAnnotation() {
194 | findsAndRunsNTests(1, TestClassWithTestTemplateAnnotation.class);
195 | }
196 |
197 | @Test
198 | void findsAndRunsTestsFromDataDrivenSpockFeature() {
199 | findsAndRunsNTests(2, TestSpecWithDataDrivenFeature.class);
200 | }
201 |
202 | @Test
203 | void findsAndRunsTestsFromClassWithNestedAnnotationAndNestedTestAnnotation() {
204 | findsAndRunsNTests(1, TestClassWithNestedAnnotationAndNestedTestAnnotation.class);
205 | findsAndRunsNTests(0, TestClassWithNestedAnnotationAndNestedTestAnnotation.NestedClass.class);
206 | }
207 |
208 | @Test
209 | void findsAndRunsTestsFromClassWithNestedAnnotationAndNestedTestFactoryAnnotation() {
210 | findsAndRunsNTests(1, TestClassWithNestedAnnotationAndNestedTestFactoryAnnotation.class);
211 | findsAndRunsNTests(0, TestClassWithNestedAnnotationAndNestedTestFactoryAnnotation.NestedClass.class);
212 | }
213 |
214 | @Test
215 | void findsAndRunsTestsWhenMultipleNesting() {
216 | findsAndRunsNTests(1, TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation.class);
217 | findsAndRunsNTests(0, TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation.NestedClass.class);
218 | findsAndRunsNTests(0, TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation.NestedClass.NestedNestedClass.class);
219 | }
220 |
221 | @Test
222 | void findsAndRunsTestsWhenMultipleNestingWithTestFactories() {
223 | findsAndRunsNTests(1, TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation.class);
224 | findsAndRunsNTests(0, TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation.NestedClass.class);
225 | findsAndRunsNTests(0, TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation.NestedClass.NestedNestedClass.class);
226 | }
227 |
228 | @Test
229 | void findsNoTestsWhenNoTestAnnotations() {
230 | findsAndRunsNTests(0, TestClassWithoutAnnotations.class);
231 | }
232 |
233 | @Test
234 | void findsNoSpockTestsWhenNoFeaturesDefined() {
235 | findsAndRunsNTests(0, TestSpecWithoutFeatures.class);
236 | }
237 |
238 | @Test
239 | void findsNoTestsInOuterClassWhenNestedAnnotationPresent() {
240 | findsAndRunsNTests(0, TestClassWithNestedClassWithNestedAnnotationAndNestedTestAnnotation.class);
241 | }
242 |
243 | @Test
244 | void findsNoTestsInOuterClassWhenNestedAnnotationPresentForFactory() {
245 | findsAndRunsNTests(0, TestClassWithNestedClassWithNestedAnnotationAndNestedTestFactoryAnnotation.class);
246 | }
247 |
248 | @Test
249 | void findsInheritedTests() {
250 | findsAndRunsNTests(1, TestClassWithInheritedTestMethod.class);
251 | }
252 |
253 | @Test
254 | void findsInheritedSpockTests() {
255 | findsAndRunsNTests(1, TestSpecWithInheritedFeature.class);
256 | }
257 |
258 | @Test
259 | void findsTestsIncludedByMethodName() {
260 | findsAndRunsNTests(1, new JUnit5TestUnitFinder(new TestGroupConfig(), singletonList("included")), TestClassWithIncludedTestMethod.class);
261 | }
262 |
263 | @Test
264 | void findsSpockTestsIncludedByMethodName() {
265 | findsAndRunsNTests(1, new JUnit5TestUnitFinder(new TestGroupConfig(), singletonList("included")), TestSpecWithIncludedFeature.class);
266 | }
267 |
268 | @Test
269 | void excludesTestsByTag() {
270 | findsAndRunsNTests(3, new JUnit5TestUnitFinder(new TestGroupConfig().withExcludedGroups("excluded"), emptyList()), TestClassWithTags.class);
271 | }
272 |
273 | @Test
274 | void excludesIsEmpty() {
275 | findsAndRunsNTests(4, new JUnit5TestUnitFinder(new TestGroupConfig().withExcludedGroups(""), emptyList()), TestClassWithTags.class);
276 | }
277 |
278 | @Test
279 | void excludesSpockTestsByTag() {
280 | findsAndRunsNTests(3, new JUnit5TestUnitFinder(new TestGroupConfig().withExcludedGroups("excluded"), emptyList()), TestSpecWithTags.class);
281 | }
282 |
283 | @Test
284 | void includesTestsByTag() {
285 | findsAndRunsNTests(1, new JUnit5TestUnitFinder(new TestGroupConfig().withIncludedGroups("included"), emptyList()), TestClassWithTags.class);
286 | }
287 |
288 | @Test
289 | void includesIsEmpty() {
290 | findsAndRunsNTests(4, new JUnit5TestUnitFinder(new TestGroupConfig().withIncludedGroups(""), emptyList()), TestClassWithTags.class);
291 | }
292 |
293 | @Test
294 | void includesSpockTestsByTag() {
295 | findsAndRunsNTests(1, new JUnit5TestUnitFinder(new TestGroupConfig().withIncludedGroups("included"), emptyList()), TestSpecWithTags.class);
296 | }
297 |
298 | @Test
299 | void findsNoTestsInAbstractTestClass() {
300 | findsAndRunsNTests(0, AbstractTestClass.class);
301 | }
302 |
303 | @Test
304 | void findsNoTestsInTestInterface() {
305 | findsAndRunsNTests(0, InterfaceTestClass.class);
306 | }
307 |
308 | @Test
309 | void findsAndRunsAbortedTest() {
310 | findsAndRunsNTests(1, TestClassWithAbortingTest.class);
311 | }
312 |
313 | @Test
314 | void findsAndRunsAbortedSpockTest() {
315 | findsAndRunsNTests(3, TestSpecWithAbortingFeature.class);
316 | }
317 |
318 | @Test
319 | void findsAndRunsTestsWithAfterAll() {
320 | findsAndRunsNTests(2, TestClassWithAfterAll.class);
321 | }
322 |
323 | @Test
324 | void findsAndRunsTestsWithCleanupSpec() {
325 | findsAndRunsNTests(2, TestSpecWithCleanupSpec.class);
326 | }
327 |
328 | @Test
329 | void findsAndRunsTestsWithBeforeAll() {
330 | findsAndRunsNTests(2, TestClassWithBeforeAll.class);
331 | }
332 |
333 | @Test
334 | void findsAndRunsTestsWithSetupSpec() {
335 | findsAndRunsNTests(2, TestSpecWithSetupSpec.class);
336 | }
337 |
338 | @Test
339 | void findsAndRunsTestsWithFailingAfterAll() {
340 | findsAndRunsNTests(2, TestClassWithFailingAfterAll.class);
341 | errorIsRecorded(t -> t instanceof AssertionFailedError, TestClassWithFailingAfterAll.class);
342 | }
343 |
344 | @Test
345 | void findsAndRunsTestsWithFailingCleanupSpec() {
346 | findsAndRunsNTests(2, TestSpecWithFailingCleanupSpec.class);
347 | }
348 |
349 | @Test
350 | void findsNoTestsWithFailingBeforeAll() {
351 | findsAndRunsNTests(0, TestClassWithFailingBeforeAll.class);
352 | }
353 |
354 | @Test
355 | void findsNoTestsWithFailingSetupSpec() {
356 | findsAndRunsNTests(0, TestSpecWithFailingSetupSpec.class);
357 | }
358 |
359 | @Test
360 | void findsNoTestsWithNestedTestClassWithoutAnnotations() {
361 | findsAndRunsNTests(0, TestClassWithNestedClassWithoutAnnotations.class);
362 | }
363 |
364 | @Test
365 | void findsAndRunsCucumberTests() {
366 | findsAndRunsNTests(1, RunCucumberTest.class);
367 | }
368 |
369 | private void findsAndRunsNTests(int n, Class> clazz) {
370 | findsAndRunsNTests(n, basicConfig(), clazz);
371 | }
372 |
373 | private void findsAndRunsNTests(int n, JUnit5TestUnitFinder underTest, Class> clazz) {
374 | RecordingListener l = run(underTest, clazz);
375 | assertThat(l.started).hasSize(n);
376 | }
377 |
378 | private void nTestsPass(int n, Class> clazz) {
379 | RecordingListener l = run(basicConfig(), clazz);
380 | assertThat(l.passed).hasSize(n);
381 | }
382 |
383 | private void nTestsFails(int n, Class> clazz) {
384 | RecordingListener l = run(basicConfig(), clazz);
385 | assertThat(l.failed).hasSize(n);
386 | }
387 |
388 | private void errorIsRecorded(Predicate p, Class> clazz) {
389 | RecordingListener l = run(basicConfig(), clazz);
390 | assertThat(l.errors).anyMatch(p);
391 | }
392 |
393 | private RecordingListener run(JUnit5TestUnitFinder underTest, Class> clazz) {
394 | RecordingListener l = new RecordingListener();
395 | underTest.findTestUnits(clazz, l);
396 | return l;
397 | }
398 |
399 | private JUnit5TestUnitFinder basicConfig() {
400 | return new JUnit5TestUnitFinder(new TestGroupConfig(), emptyList());
401 | }
402 |
403 | }
404 |
405 | class RecordingListener implements TestUnitExecutionListener {
406 | List started = new ArrayList<>();
407 | List failed = new ArrayList<>();
408 | List passed = new ArrayList<>();
409 |
410 | List errors = new ArrayList<>();
411 |
412 | @Override
413 | public void executionStarted(Description description) {
414 | started.add(description);
415 | }
416 |
417 | @Override
418 | public void executionFinished(Description description, boolean pass, Throwable optional) {
419 | if (pass) {
420 | passed.add(description);
421 | } else {
422 | failed.add(description);
423 | }
424 |
425 | if (optional != null) {
426 | errors.add(optional);
427 | }
428 | }
429 | }
430 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/JUnit5TestUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5;
16 |
17 | import static java.util.Collections.emptyList;
18 | import static org.assertj.core.api.Assertions.assertThat;
19 |
20 | import java.util.ArrayList;
21 | import java.util.List;
22 | import java.util.Optional;
23 |
24 | import org.junit.jupiter.api.Test;
25 | import org.pitest.junit5.repository.TestClassWithAbortingTest;
26 | import org.pitest.junit5.repository.TestClassWithAfterAll;
27 | import org.pitest.junit5.repository.TestClassWithBeforeAll;
28 | import org.pitest.junit5.repository.TestClassWithFailingAfterAll;
29 | import org.pitest.junit5.repository.TestClassWithFailingBeforeAll;
30 | import org.pitest.junit5.repository.TestClassWithFailingTest;
31 | import org.pitest.junit5.repository.TestClassWithInheritedTestMethod;
32 | import org.pitest.junit5.repository.TestClassWithNestedAnnotationAndNestedTestAnnotation;
33 | import org.pitest.junit5.repository.TestClassWithNestedAnnotationAndNestedTestFactoryAnnotation;
34 | import org.pitest.junit5.repository.TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation;
35 | import org.pitest.junit5.repository.TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation;
36 | import org.pitest.junit5.repository.TestClassWithTestAnnotation;
37 | import org.pitest.junit5.repository.TestClassWithTestFactoryAnnotation;
38 | import org.pitest.testapi.Description;
39 | import org.pitest.testapi.NullExecutionListener;
40 | import org.pitest.testapi.ResultCollector;
41 | import org.pitest.testapi.TestGroupConfig;
42 |
43 | /**
44 | *
45 | * @author tobias
46 | */
47 | class JUnit5TestUnitTest {
48 |
49 | @Test
50 | void testTestClassWithTestAnnotation() {
51 | TestResultCollector resultCollector = findTestsIn(TestClassWithTestAnnotation.class);
52 |
53 | assertThat(resultCollector.getSkipped()).isEmpty();
54 | assertThat(resultCollector.getStarted()).hasSize(1);
55 | assertThat(resultCollector.getEnded()).hasSize(1);
56 | }
57 |
58 | @Test
59 | void test3TestClassWithTestFactoryAnnotation() {
60 | TestResultCollector resultCollector = findTestsIn(TestClassWithTestFactoryAnnotation.class);
61 |
62 | assertThat(resultCollector.getSkipped()).isEmpty();
63 | assertThat(resultCollector.getStarted()).hasSize(1);
64 | assertThat(resultCollector.getEnded()).hasSize(1);
65 | }
66 |
67 | @Test
68 | void testTestClassWithNestedAnnotationAndNestedTestAnnotation() {
69 | TestResultCollector resultCollector =
70 | findTestsIn(TestClassWithNestedAnnotationAndNestedTestAnnotation.class);
71 |
72 | assertThat(resultCollector.getSkipped()).isEmpty();
73 | assertThat(resultCollector.getStarted()).hasSize(1);
74 | assertThat(resultCollector.getEnded()).hasSize(1);
75 | }
76 |
77 |
78 | @Test
79 | void testTestClassWithNestedAnnotationAndNestedTestFactoryAnnotation() {
80 | TestResultCollector resultCollector =
81 | findTestsIn(TestClassWithNestedAnnotationAndNestedTestFactoryAnnotation.class);
82 |
83 | assertThat(resultCollector.getSkipped()).isEmpty();
84 | assertThat(resultCollector.getStarted()).hasSize(1);
85 | assertThat(resultCollector.getEnded()).hasSize(1);
86 | }
87 |
88 | @Test
89 | void testTestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation() {
90 | TestResultCollector resultCollector =
91 | findTestsIn(TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation.class);
92 |
93 | assertThat(resultCollector.getSkipped()).isEmpty();
94 | assertThat(resultCollector.getStarted()).hasSize(1);
95 | assertThat(resultCollector.getEnded()).hasSize(1);
96 | }
97 |
98 | @Test
99 | void testTestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation() {
100 | TestResultCollector resultCollector =
101 | findTestsIn(TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation.class);
102 |
103 | assertThat(resultCollector.getSkipped()).isEmpty();
104 | assertThat(resultCollector.getStarted()).hasSize(1);
105 | assertThat(resultCollector.getEnded()).hasSize(1);
106 | }
107 |
108 | @Test
109 | void testTestClassWithInheritedTestMethod() {
110 | TestResultCollector resultCollector =
111 | findTestsIn(TestClassWithInheritedTestMethod.class);
112 |
113 | assertThat(resultCollector.getSkipped()).isEmpty();
114 | assertThat(resultCollector.getStarted()).hasSize(1);
115 | assertThat(resultCollector.getEnded()).hasSize(1);
116 | }
117 |
118 | @Test
119 | void testTestClassWithFailingTest() {
120 | TestResultCollector resultCollector = findTestsIn(TestClassWithFailingTest.class);
121 |
122 | assertThat(resultCollector.getSkipped()).isEmpty();
123 | assertThat(resultCollector.getStarted()).hasSize(1);
124 | assertThat(resultCollector.getEnded()).hasSize(1);
125 | assertThat(resultCollector.getFailure()).isPresent();
126 | }
127 |
128 | @Test
129 | void testTestClassWithAbortingTest() {
130 | TestResultCollector resultCollector = findTestsIn(TestClassWithAbortingTest.class);
131 |
132 | assertThat(resultCollector.getSkipped()).isEmpty();
133 | assertThat(resultCollector.getStarted()).hasSize(1);
134 | assertThat(resultCollector.getEnded()).hasSize(1);
135 | assertThat(resultCollector.getFailure()).isEmpty();
136 | }
137 |
138 | @Test
139 | void testRunsBeforeAlls() {
140 | TestResultCollector resultCollector = findTestsIn(TestClassWithBeforeAll.class);
141 |
142 | assertThat(resultCollector.getSkipped()).isEmpty();
143 | assertThat(resultCollector.getStarted()).hasSize(2);
144 | assertThat(resultCollector.getFailure()).isEmpty();
145 | }
146 |
147 | @Test
148 | void testFailsWhenBeforeAllFails() {
149 | TestResultCollector resultCollector = findTestsIn(TestClassWithFailingBeforeAll.class);
150 |
151 | assertThat(resultCollector.getSkipped()).isEmpty();
152 | assertThat(resultCollector.getStarted()).hasSize(0);
153 | assertThat(resultCollector.getFailure()).isPresent();
154 | }
155 |
156 | @Test
157 | void runsAfterAlls() {
158 | TestResultCollector resultCollector = findTestsIn(TestClassWithAfterAll.class);
159 |
160 | assertThat(resultCollector.getSkipped()).isEmpty();
161 | assertThat(resultCollector.getStarted()).hasSize(2);
162 | assertThat(resultCollector.getFailure()).isEmpty();
163 | }
164 |
165 | @Test
166 | void testFailsWhenAfterAllFails() {
167 | TestResultCollector resultCollector = findTestsIn(TestClassWithFailingAfterAll.class);
168 |
169 | assertThat(resultCollector.getSkipped()).isEmpty();
170 | // We get 4 start notifications, 1 for each test and again for the container. Not clear
171 | // what consequence this has.
172 | //assertThat(resultCollector.getStarted()).hasSize(2);
173 | assertThat(resultCollector.getFailure()).isPresent();
174 | }
175 |
176 | private TestResultCollector findTestsIn(Class> clazz) {
177 | TestResultCollector resultCollector = new TestResultCollector();
178 | new JUnit5TestUnitFinder(new TestGroupConfig(), emptyList()).findTestUnits(clazz, new NullExecutionListener())
179 | .stream()
180 | .forEach(testUnit -> testUnit.execute(resultCollector));
181 | return resultCollector;
182 | }
183 |
184 | private static class TestResultCollector implements ResultCollector {
185 |
186 | private final List skipped = new ArrayList<>();
187 | private final List started = new ArrayList<>();
188 | private final List ended = new ArrayList<>();
189 | private volatile Throwable failure;
190 |
191 | @Override
192 | public void notifyEnd(Description description, Throwable t) {
193 | this.failure = t;
194 | notifyEnd(description);
195 | }
196 |
197 | @Override
198 | public void notifyEnd(Description description) {
199 | ended.add(description);
200 | }
201 |
202 | @Override
203 | public void notifyStart(Description description) {
204 | started.add(description);
205 | }
206 |
207 | @Override
208 | public void notifySkipped(Description description) {
209 | skipped.add(description);
210 | }
211 |
212 | @Override
213 | public boolean shouldExit() {
214 | return false;
215 | }
216 |
217 | public List getSkipped() {
218 | return skipped;
219 | }
220 |
221 | public List getStarted() {
222 | return started;
223 | }
224 |
225 | public List getEnded() {
226 | return ended;
227 | }
228 |
229 | public Optional getFailure() {
230 | return Optional.ofNullable(failure);
231 | }
232 |
233 | }
234 |
235 | }
236 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/cucumber/Glue.java:
--------------------------------------------------------------------------------
1 | package org.pitest.junit5.cucumber;
2 |
3 | import io.cucumber.java8.En;
4 |
5 | public class Glue implements En {
6 |
7 | public Glue() {
8 | Given("an initial step", () -> {
9 | });
10 | When("an action step", () -> {
11 | });
12 | Then("a check step", () -> {
13 | });
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/cucumber/RunCucumberTest.java:
--------------------------------------------------------------------------------
1 | package org.pitest.junit5.cucumber;
2 |
3 | import io.cucumber.junit.platform.engine.Cucumber;
4 |
5 | @Cucumber
6 | public class RunCucumberTest {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/AbstractTestClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import java.util.Collection;
18 | import java.util.Collections;
19 | import org.junit.jupiter.api.DynamicTest;
20 | import org.junit.jupiter.api.Test;
21 | import org.junit.jupiter.api.TestFactory;
22 |
23 | /**
24 | *
25 | * @author Tobias Stadler
26 | */
27 | public abstract class AbstractTestClass {
28 |
29 | @Test
30 | void test() {
31 | }
32 |
33 | @TestFactory
34 | Collection testFactory() {
35 | return Collections.emptyList();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/InterfaceTestClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import java.util.Collection;
18 | import org.junit.jupiter.api.DynamicTest;
19 | import org.junit.jupiter.api.Test;
20 | import org.junit.jupiter.api.TestFactory;
21 |
22 | /**
23 | *
24 | * @author Tobias Stadler
25 | */
26 | public interface InterfaceTestClass {
27 |
28 | @Test
29 | void Test();
30 |
31 | @TestFactory
32 | Collection testFactory();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/ParameterizedNoExplicitSource.java:
--------------------------------------------------------------------------------
1 | package org.pitest.junit5.repository;
2 |
3 | import org.junit.jupiter.params.ParameterizedTest;
4 | import org.junit.jupiter.params.provider.MethodSource;
5 |
6 | import java.util.stream.Stream;
7 |
8 | public class ParameterizedNoExplicitSource {
9 |
10 | @ParameterizedTest
11 | @MethodSource()
12 | public void parameterizedTest(String string) {
13 |
14 | }
15 |
16 | static Stream parameterizedTest() {
17 | return Stream.of("foo", "bar");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import org.junit.jupiter.api.Test;
18 |
19 | /**
20 | * @author Tobias Stadler
21 | */
22 | public class TestClass {
23 |
24 | @Test
25 | public void test() {
26 |
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithAbortingTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import org.junit.jupiter.api.Test;
18 |
19 | import static org.junit.jupiter.api.Assumptions.assumeTrue;
20 |
21 | /**
22 | *
23 | * @author Tobias Stadler
24 | */
25 | public class TestClassWithAbortingTest {
26 |
27 | @Test
28 | public void test() {
29 | assumeTrue(false);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithAfterAll.java:
--------------------------------------------------------------------------------
1 | package org.pitest.junit5.repository;
2 |
3 | import org.junit.jupiter.api.AfterAll;
4 | import org.junit.jupiter.api.Test;
5 |
6 | public class TestClassWithAfterAll {
7 |
8 | @AfterAll
9 | static void hello() {
10 |
11 | }
12 |
13 | @Test
14 | void aTest() {
15 |
16 | }
17 |
18 | @Test
19 | void anotherTest() {
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithBeforeAll.java:
--------------------------------------------------------------------------------
1 | package org.pitest.junit5.repository;
2 |
3 | import org.junit.jupiter.api.BeforeAll;
4 | import org.junit.jupiter.api.Test;
5 |
6 | import static org.junit.jupiter.api.Assertions.fail;
7 |
8 | public class TestClassWithBeforeAll {
9 | static boolean fail = true;
10 |
11 | @BeforeAll
12 | static void fails() {
13 | fail = false;
14 | }
15 |
16 | @Test
17 | void aTest() {
18 | if (fail) {
19 | fail();
20 | }
21 | }
22 |
23 | @Test
24 | void anotherTest() {
25 | if (fail) {
26 | fail();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithFailingAfterAll.java:
--------------------------------------------------------------------------------
1 | package org.pitest.junit5.repository;
2 |
3 | import org.junit.jupiter.api.AfterAll;
4 | import org.junit.jupiter.api.Test;
5 |
6 | import static org.junit.jupiter.api.Assertions.fail;
7 |
8 | public class TestClassWithFailingAfterAll {
9 |
10 | @AfterAll
11 | static void oops() {
12 | fail();
13 | }
14 |
15 | @Test
16 | void aTest() {
17 |
18 | }
19 |
20 | @Test
21 | void anotherTest() {
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithFailingBeforeAll.java:
--------------------------------------------------------------------------------
1 | package org.pitest.junit5.repository;
2 |
3 | import org.junit.jupiter.api.BeforeAll;
4 | import org.junit.jupiter.api.Test;
5 |
6 | import static org.junit.jupiter.api.Assertions.fail;
7 |
8 | public class TestClassWithFailingBeforeAll {
9 |
10 | @BeforeAll
11 | static void fails() {
12 | fail();
13 | }
14 |
15 | @Test
16 | void aTest() {
17 |
18 | }
19 |
20 | @Test
21 | void anotherTest() {
22 |
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithFailingTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import org.junit.jupiter.api.Test;
18 |
19 | import static org.junit.jupiter.api.Assertions.assertTrue;
20 |
21 | /**
22 | *
23 | * @author Tobias Stadler
24 | */
25 | public class TestClassWithFailingTest {
26 |
27 | @Test
28 | public void test() {
29 | assertTrue(false);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithIncludedTestMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import org.junit.jupiter.api.Test;
18 |
19 | /**
20 | * @author Tobias Stadler
21 | */
22 | public class TestClassWithIncludedTestMethod {
23 |
24 | @Test
25 | public void test() {
26 |
27 | }
28 |
29 | @Test
30 | public void included() {
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithInheritedTestMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | /**
18 | * @author Tobias Stadler
19 | */
20 | public class TestClassWithInheritedTestMethod extends TestClass {
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithMixedPassAndFail.java:
--------------------------------------------------------------------------------
1 | package org.pitest.junit5.repository;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | import static org.junit.jupiter.api.Assertions.fail;
6 |
7 | public class TestClassWithMixedPassAndFail {
8 |
9 | @Test
10 | void passingTest() {
11 |
12 | }
13 |
14 | @Test
15 | void passingTest2() {
16 |
17 | }
18 |
19 | @Test
20 | void failingTest() {
21 | fail();
22 | }
23 |
24 | @Test
25 | void erroringTest() {
26 | throw new RuntimeException();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithMultiplePassingTests.java:
--------------------------------------------------------------------------------
1 | package org.pitest.junit5.repository;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | public class TestClassWithMultiplePassingTests {
6 |
7 | @Test
8 | void testOne() {
9 |
10 | }
11 |
12 | @Test
13 | void testTwo() {
14 |
15 | }
16 |
17 | @Test
18 | void testThree() {
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithNestedAnnotationAndNestedTestAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import org.junit.jupiter.api.Nested;
18 | import org.junit.jupiter.api.Test;
19 |
20 | /**
21 | *
22 | * @author Tobias Stadler
23 | */
24 | public class TestClassWithNestedAnnotationAndNestedTestAnnotation {
25 |
26 | @Nested
27 | public class NestedClass {
28 |
29 | @Test
30 | public void test() {
31 |
32 | }
33 |
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithNestedAnnotationAndNestedTestFactoryAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import java.util.Collection;
18 | import java.util.Collections;
19 | import org.junit.jupiter.api.DynamicTest;
20 | import org.junit.jupiter.api.Nested;
21 | import org.junit.jupiter.api.TestFactory;
22 |
23 | /**
24 | *
25 | * @author Tobias Stadler
26 | */
27 | public class TestClassWithNestedAnnotationAndNestedTestFactoryAnnotation {
28 |
29 | @Nested
30 | public class NestedClass {
31 |
32 | @TestFactory
33 | public Collection testFactory() {
34 | return Collections.singleton(DynamicTest.dynamicTest("dynamic test", () -> {}));
35 | }
36 |
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import org.junit.jupiter.api.Nested;
18 | import org.junit.jupiter.api.Test;
19 |
20 | /**
21 | *
22 | * @author Tobias Stadler
23 | */
24 | public class TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation {
25 |
26 | @Nested
27 | public class NestedClass {
28 |
29 | @Nested
30 | public class NestedNestedClass {
31 |
32 | @Test
33 | public void test() {
34 |
35 | }
36 |
37 | }
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import java.util.Collection;
18 | import java.util.Collections;
19 | import org.junit.jupiter.api.DynamicTest;
20 | import org.junit.jupiter.api.Nested;
21 | import org.junit.jupiter.api.TestFactory;
22 |
23 | /**
24 | *
25 | * @author Tobias Stadler
26 | */
27 | public class TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation {
28 |
29 | @Nested
30 | public class NestedClass {
31 |
32 | @Nested
33 | public class NestedNestedClass {
34 |
35 | @TestFactory
36 | public Collection testFactory() {
37 | return Collections.singleton(DynamicTest.dynamicTest("dynamic test", () -> {}));
38 | }
39 |
40 | }
41 |
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithNestedClassWithNestedAnnotationAndNestedTestAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import org.junit.jupiter.api.Nested;
18 | import org.junit.jupiter.api.Test;
19 |
20 | /**
21 | *
22 | * @author Tobias Stadler
23 | */
24 | public class TestClassWithNestedClassWithNestedAnnotationAndNestedTestAnnotation {
25 |
26 | public class NestedClass {
27 |
28 | @Nested
29 | public class NestedNestedClass {
30 |
31 | @Test
32 | public void test() {
33 |
34 | }
35 |
36 | }
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithNestedClassWithNestedAnnotationAndNestedTestFactoryAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import org.junit.jupiter.api.Nested;
18 | import org.junit.jupiter.api.Test;
19 |
20 | /**
21 | *
22 | * @author Tobias Stadler
23 | */
24 | public class TestClassWithNestedClassWithNestedAnnotationAndNestedTestFactoryAnnotation {
25 |
26 | public class NestedClass {
27 |
28 | @Nested
29 | public class NestedNestedClass {
30 |
31 | @Test
32 | public void test() {
33 |
34 | }
35 |
36 | }
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithNestedClassWithoutAnnotations.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import java.util.Collection;
18 | import java.util.Collections;
19 | import org.junit.jupiter.api.DynamicTest;
20 |
21 | /**
22 | *
23 | * @author Tobias Stadler
24 | */
25 | public class TestClassWithNestedClassWithoutAnnotations {
26 |
27 | public static class NestedClasss {
28 |
29 | public void test() {
30 |
31 | }
32 |
33 | public Collection testFactory() {
34 | return Collections.emptyList();
35 | }
36 |
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithParameterizedTestAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import java.util.stream.Stream;
18 | import org.junit.jupiter.params.ParameterizedTest;
19 | import org.junit.jupiter.params.provider.Arguments;
20 | import org.junit.jupiter.params.provider.MethodSource;
21 | import org.junit.jupiter.params.provider.ValueSource;
22 |
23 | /**
24 | *
25 | * @author Tobias Stadler
26 | */
27 | public class TestClassWithParameterizedTestAnnotation {
28 |
29 | @ParameterizedTest
30 | @ValueSource(strings = {"hello", "goodbye"})
31 | public void parameterizedTest(String string) {
32 |
33 | }
34 |
35 | @ParameterizedTest
36 | @MethodSource("someMethod")
37 | public void methodParameterizedTest(String string) {
38 |
39 | }
40 |
41 | static Stream someMethod() {
42 | return Stream.of(Arguments.of("foo"), Arguments.of("bar"));
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithRepeatedTestAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import org.junit.jupiter.api.RepeatedTest;
18 |
19 | /**
20 | *
21 | * @author Tobias Stadler
22 | */
23 | public class TestClassWithRepeatedTestAnnotation {
24 |
25 | @RepeatedTest(1)
26 | public void repeatedTest() {
27 |
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithTags.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import org.junit.jupiter.api.Tag;
18 | import org.junit.jupiter.api.Test;
19 |
20 | /**
21 | *
22 | * @author Tobias Stadler
23 | */
24 | public class TestClassWithTags {
25 |
26 | @Test
27 | public void testWithoutTag() {
28 |
29 | }
30 |
31 | @Test
32 | @Tag("foo")
33 | public void testWithTag() {
34 |
35 | }
36 |
37 | @Test
38 | @Tag("included")
39 | public void testWithIncludedTag() {
40 |
41 | }
42 |
43 | @Test
44 | @Tag("excluded")
45 | public void testWithExcludedTag() {
46 |
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithTestAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import org.junit.jupiter.api.Test;
18 |
19 | /**
20 | *
21 | * @author Tobias Stadler
22 | */
23 | public class TestClassWithTestAnnotation {
24 |
25 | @Test
26 | public void test() {
27 |
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithTestFactoryAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import java.util.Collection;
18 | import java.util.Collections;
19 | import org.junit.jupiter.api.DynamicTest;
20 | import org.junit.jupiter.api.TestFactory;
21 |
22 | /**
23 | *
24 | * @author Tobias Stadler
25 | */
26 | public class TestClassWithTestFactoryAnnotation {
27 |
28 | @TestFactory
29 | public Collection testFactory() {
30 | return Collections.singleton(DynamicTest.dynamicTest("dynamic test", () -> {}));
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithTestTemplateAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Tobias Stadler
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing,
11 | * software distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and limitations under the License.
14 | */
15 | package org.pitest.junit5.repository;
16 |
17 | import org.junit.jupiter.api.TestTemplate;
18 | import org.junit.jupiter.api.extension.ExtendWith;
19 | import org.junit.jupiter.api.extension.ExtensionContext;
20 | import org.junit.jupiter.api.extension.TestTemplateInvocationContext;
21 | import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider;
22 |
23 | import java.util.stream.Stream;
24 |
25 | /**
26 | *
27 | * @author Tobias Stadler
28 | */
29 | public class TestClassWithTestTemplateAnnotation {
30 |
31 | public static class MyTestTemplateInvocationContextProvider implements TestTemplateInvocationContextProvider {
32 | @Override
33 | public boolean supportsTestTemplate(ExtensionContext context) {
34 | return true;
35 | }
36 |
37 | @Override
38 | public Stream provideTestTemplateInvocationContexts(ExtensionContext context) {
39 | return Stream.of(new TestTemplateInvocationContext() {
40 | });
41 | }
42 |
43 | }
44 |
45 | @TestTemplate
46 | @ExtendWith(MyTestTemplateInvocationContextProvider.class)
47 | public void testTemplate() {
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/test/java/org/pitest/junit5/repository/TestClassWithoutAnnotations.java:
--------------------------------------------------------------------------------
1 | package org.pitest.junit5.repository;
2 |
3 | import java.util.Collection;
4 | import java.util.Collections;
5 | import org.junit.jupiter.api.DynamicTest;
6 |
7 | /**
8 | *
9 | * @author Tobias Stadler
10 | */
11 | public class TestClassWithoutAnnotations {
12 |
13 | public void test() {
14 |
15 | }
16 |
17 | public Collection testFactory() {
18 | return Collections.emptyList();
19 | }
20 |
21 | public static class NestedClasss {
22 |
23 | public void test() {
24 |
25 | }
26 |
27 | public Collection testFactory() {
28 | return Collections.emptyList();
29 | }
30 |
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/resources/org/pitest/junit5/cucumber/pitest-junit5-cucumber.feature:
--------------------------------------------------------------------------------
1 | Feature: pitest-junit5-cucumber
2 |
3 | Scenario: a cucumber scenario is found
4 | Given an initial step
5 | When an action step
6 | Then a check step
7 |
--------------------------------------------------------------------------------