Comments (14)
@Tibor17 Please comment on why you think our existing config should not work, even though it does! 😉
from junit5-samples.
We can check AbstractSurefireMojo
if really needed. This is to my memory that we pickup such artifact which has Surefire SPI. This artifact is provided in classpath when you run your test. Surefire documented adding provider in plugin's dependency section.
Is there any reason to not to use project dependencies?
from junit5-samples.
Pls follow #26.
from junit5-samples.
The reason to not use project dependencies is that the classes included via the plugin dependencies are not on the classpath for the test writer (but are available to the plugin itself). That's the original impetus for the current documentation and sample.
from junit5-samples.
But everything must be on classpath; otherwise the forked jvm would not run. Consider you use forkCount=5
in Surefire configuration. If you start very long term running test class go to target/surefire/
and copy jar file from it to a safe folder. Open it and to go manifest. You will see Class-Path header. This is the classpath the ForkedBooter
has, which includes provider, all transitive dependencies and project dependencies with scope=test.
from junit5-samples.
Last to mention, the plugin (plugin's ClassLoader) does not need to have your dependencies. The point is that plugin starts forked JVM where all jar files reside. This means plugin != provider. Provider and plugin is isolated. Mostly on the level of jvm processes, or ClassLoader (if forkCount=0) within one process. The default and usual is process isolation.
from junit5-samples.
So apparently I'm not running into issues because I'm hardly using the junit-vintage-engine
and the junit-jupiter-engine
doesn't support forking through the junit-platform-surefire-provider
.
from junit5-samples.
The plugin itself does forking. This means, simply the plugin creates jar file with manifest having Class-Path, the plugin is then executing java -jar target/surefire/1234567890.jar
. The Class-Path is pointing to jars located in your local repository e.g. ~/.m2/repository
.
from junit5-samples.
This is what MANIFEST.MF
looks like for our sample project (cf. POM):
Manifest-Version: 1.0
Class-Path: file:/Users/marcp/.m2/repository/org/apache/maven/surefire
/surefire-booter/2.19.1/surefire-booter-2.19.1.jar file:/Users/marcp/
.m2/repository/org/apache/maven/surefire/surefire-api/2.19.1/surefire
-api-2.19.1.jar file:/Users/marcp/Repositories/junit5-samples/junit5-
maven-consumer/target/test-classes/ file:/Users/marcp/Repositories/ju
nit5-samples/junit5-maven-consumer/target/classes/ file:/Users/marcp/
.m2/repository/org/junit/jupiter/junit-jupiter-api/5.0.0-M4/junit-jup
iter-api-5.0.0-M4.jar file:/Users/marcp/.m2/repository/org/opentest4j
/opentest4j/1.0.0-M2/opentest4j-1.0.0-M2.jar file:/Users/marcp/.m2/re
pository/org/junit/platform/junit-platform-commons/1.0.0-M4/junit-pla
tform-commons-1.0.0-M4.jar file:/Users/marcp/.m2/repository/junit/jun
it/4.12/junit-4.12.jar file:/Users/marcp/.m2/repository/org/hamcrest/
hamcrest-core/1.3/hamcrest-core-1.3.jar file:/Users/marcp/.m2/reposit
ory/org/junit/platform/junit-platform-surefire-provider/1.0.0-M4/juni
t-platform-surefire-provider-1.0.0-M4.jar file:/Users/marcp/.m2/repos
itory/org/junit/platform/junit-platform-launcher/1.0.0-M4/junit-platf
orm-launcher-1.0.0-M4.jar file:/Users/marcp/.m2/repository/org/apache
/maven/surefire/common-java5/2.19.1/common-java5-2.19.1.jar file:/Use
rs/marcp/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.0.0-
M4/junit-jupiter-engine-5.0.0-M4.jar file:/Users/marcp/.m2/repository
/org/junit/platform/junit-platform-engine/1.0.0-M4/junit-platform-eng
ine-1.0.0-M4.jar file:/Users/marcp/.m2/repository/org/junit/vintage/j
unit-vintage-engine/4.12.0-M4/junit-vintage-engine-4.12.0-M4.jar file
:/Users/marcp/.m2/repository/org/apache/maven/reporting/maven-reporti
ng-api/3.0/maven-reporting-api-3.0.jar
Main-Class: org.apache.maven.surefire.booter.ForkedBooter
As you can see all the dependencies listed in the plugin configuration's dependencies section are on the classpath. Thus, I do not see a problem with our recommended configuration.
@Tibor17 Do you want to double-check AbstractSurefireMojo
?
from junit5-samples.
I had a project and tested this both ways when I originally was trying to minimize the classpath used in the test scope. Since the JUnit 5 provider is single-threaded, I've never seen an issue. I'm relying on @Tibor17 to describe the requirements for a threaded provider.
from junit5-samples.
The above MANIFEST.MF is from a run with <forkCount>4</forkCount>
and it does indeed fork and run tests in parallel (in different VMs) without any issue.
from junit5-samples.
@marcphilipp - Then I vote to keep the current configuration as well. I like the fact that the engine classes aren't available to the test writer.
from junit5-samples.
@Tibor17 Do you want to take another look?
from junit5-samples.
Haven't heard back from @Tibor17 but I'm going ahead and closing this and the related #26, junit-team/junit5#848, and junit-team/junit5#849.
from junit5-samples.
Related Issues (20)
- Consider moving to a public domain licence HOT 5
- Please cite best practice for not excluding maven-wrapper.jar HOT 4
- Use Apache Ivy in Ant examples
- Upgradle to 6.0.1 HOT 1
- Help | Is there any way I can add @Tags dynamically from Test Data HOT 1
- Use HTTPS
- Add Android integration test project HOT 1
- Issue with JUnit after finishing Level 10 HOT 1
- build.gradle.kts and tag expressions HOT 2
- How to use TestPipeline HOT 3
- 5.7.1 breaks Bazel sample HOT 13
- DisplayName tag not working properly in junit5-jupiter-starter-maven example HOT 4
- Add module-info.java to have an example that works with Jigsaw too. HOT 1
- Add `junit5-jupiter-starter-graalvm-native` sample HOT 5
- Build broken when using kotlin 1.7.21 HOT 4
- Update used GitHub Actions HOT 2
- Bazel starter issues a deprecation warning HOT 4
- junit5-jupiter-starter-gradle @ParameterizedTest name not displaying HOT 2
- Groovy HOT 2
- Intellij IDE shows 'no name' for a kotlin-bazel project HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from junit5-samples.