New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use internal custom TestEngine implementations in Maven-Surefire-Plugin? #1632
Comments
What are external and internal engines? Do you have a |
Here is an integration test showing how to include three engines in a Basically, any test engine implementation available at test runtime (via |
Project structure
|
I overwrote discover and execute methods in a way that engineExecutionListener fires "start" and "finish" for the root and one child. Internal = same maven project |
Are you extending |
I don't extend from JupiterTestEngine as that test engine will build tests from other resources (i.e. XML files). I use launcher only to see if LauncherConfig works or (for the future) if DiscoverySelectors work properly.
|
Can you please move your |
What is listed in Surefire's |
unfortunately moving it to main didn't help. Also I couldn't find any useful information in debug mode about class path. The only line i could find with class path was
|
What happens if you move |
This is not a |
Already did, same result: nothing |
Does this help you?
|
Below those configurations there should be line like |
At "maven-compiler-plugin":
Surefire didn't display any classpath informations |
Does
Strange... |
When they are under |
Some more suggestions:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit-platform</artifactId>
<version>2.22.1</version>
</dependency>
</dependencies>
</plugin> For details see https://maven.apache.org/surefire/maven-surefire-plugin/examples/providers.html Got it working with the |
I made the suggested changes, but I don't get this last part of yours. Maybe Surefire is handling test discovery from a TestEngine differently then DefaultLauncher.
Here my pom.xml:
And here is MyTestEngine.java
|
I guess this is a maven issue and not an JUnit platform issue. I did following steps which resulted in executing my test:
Maybe Surefire only consideres other TestEngine implementations if it finds at least one from JUnit. |
I'd like to close this ticket as this is definitely a feature of Surefire. Following reasons:
Maybe this should be mentioned in JUnit 5 User Guide Chapter Configuring Test Engines. |
Maven's default patterns and filtering are mentioned in the User Guide: https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven-filter-test-class-names That section also links to: https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html Are you saying the User Guide should do more than it already does in this regard? |
OK. I'm closing it for you now. |
Surefire should select the correct Framework Provider automatically: having |
For developing custom TestEngine classes there already is a lot of documentation on how to use them:
Well, I tried to use a custom TestEngine with ServiceLoader (intern), it works fine in IntelliJ or using a Launcher, but I didn't get anything while running mvn test.
In Maven Surefire documentation it's mentioned that you only need to add JUnit-Jupiter-Engine in dependencies without the help of an provider. But these engines are external. What about internal engines?
The text was updated successfully, but these errors were encountered: