Skip to content
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

Beginning with 1.7.1 standalone console does not find tests on Java 8 #2600

Closed
ndimitry opened this issue Apr 23, 2021 · 8 comments · Fixed by #2613
Closed

Beginning with 1.7.1 standalone console does not find tests on Java 8 #2600

ndimitry opened this issue Apr 23, 2021 · 8 comments · Fixed by #2613

Comments

@ndimitry
Copy link

ndimitry commented Apr 23, 2021

Steps to reproduce

We are launching tests with the following command:

java -cp ./junit-platform-console-standalone-1.7.1.jar:./jar-file-with-tests.jar org.junit.platform.console.ConsoleLauncher --select-package=root.package.for.all.tests --reports-dir /specified/path

jar-file-with-tests.jar does contain a lot of classes with methods marked with @Test annotation.

This command works fine when:

  • we use junit-platform-console-standalone version 1.7.0 both on Java 8 and Java 11
  • we use junit-platform-console-standalone version 1.7.1 or 1.8.0-M1 on Java 11

When launching 1.7.1 console on Java 8 the report states that 2 containers were found (2 containers found, 2 containers started and 2 containers successful), no tests are present in the report (all other values in the report are 0 (like 0 tests found))

Context

The testing project (jar-file-with-tests.jar) is built using Java 8.

Issue seems to occur both in Windows and Linux environments.

@sormuras sormuras self-assigned this Apr 23, 2021
@sbrannen sbrannen changed the title Starting from version 5.7.1 (1.7.1) standalone console is not finding tests when running on Java8 Beginning with 5.7.1 (1.7.1) standalone console does not find tests on Java 8 Apr 23, 2021
@sbrannen sbrannen changed the title Beginning with 5.7.1 (1.7.1) standalone console does not find tests on Java 8 Beginning with 1.7.1 standalone console does not find tests on Java 8 Apr 23, 2021
@ndimitry
Copy link
Author

Colleagues use a framework based on JUnit 5 with some enhancements needed for our project. In case they use JUnit 5.7.1 (jupiter) they also faced the same problem: tests were not discovered on Java8.
So possibly this issue is connected with some code reused for both jupiter and platform.

@marcphilipp
Copy link
Member

Potentially related to junit-team/junit5-samples#146

@marcphilipp
Copy link
Member

Potentially caused by #2500

@marcphilipp marcphilipp added this to the 5.7.2 milestone Apr 23, 2021
@ndimitry
Copy link
Author

ndimitry commented Apr 23, 2021

Metadata (MANIFEST.MF) of the testing project contains option
Multi-Release: true
Testing project contains no main class.
It was built with no module mentioned in the pom file (no module-info class is present). When I execute (on java11):

java -p jar-file-with-tests.jar --list-modules

I get no modules for the testing project (possibly I should change that).

@sormuras
Copy link
Member

jar-file-with-tests.jar does contain a lot of classes with methods marked with @Test annotation.

Can you provide us that jar-file-with-tests.jar file in order to reproduce this issue you describe? Or better, create a minimal version of it?

Multi-Release: true and Java modules should not matter when running on Java 8. Btw, which exact version of Java 8 do you use?

@sormuras
Copy link
Member

Setup

I could reproduce this bug using the following incredients/commands with JDK 17-ea+19:

package sample;
class SampleTests { @org.junit.jupiter.api.Test void sample() {} }
  • javac --release 8 --class-path junit-platform-console-standalone-1.7.0.jar -d classes SampleTests.java
  • jar --create --file tests.jar -C classes .
  • jar --list --file tests.jar
META-INF/
META-INF/MANIFEST.MF
sample/
sample/SampleTests.class

✔ Expected Output

.
+-- JUnit Jupiter [OK]                  
| '-- SampleTests [OK]                  
|   '-- sample() [OK]
'-- JUnit Vintage [OK]

❌ Wrong Output

+-- JUnit Jupiter [OK]
'-- JUnit Vintage [OK]

ConsoleLauncher 1.7.0

java -cp junit-platform-console-standalone-1.7.0.jar;tests.jar org.junit.platform.console.ConsoleLauncher --select-package sample

  • ✔ Java 8
  • ✔ Java 17

ConsoleLauncher 1.7.1

java -cp junit-platform-console-standalone-1.7.1.jar;tests.jar org.junit.platform.console.ConsoleLauncher --select-package sample

  • ❌ Java 8
  • ✔ Java 17

ConsoleLauncher 1.8.0-M1

java -cp junit-platform-console-standalone-1.8.0-M1.jar;tests.jar org.junit.platform.console.ConsoleLauncher --select-package sample

  • ❌ Java 8
  • ✔ Java 17

@ndimitry
Copy link
Author

@sormuras thank you for reproducing this issue!

sormuras added a commit that referenced this issue May 11, 2021
Fix `getRootUrisForPackage()` in class `ClasspathScanner` by looking for two
"wordings" of a package name.

For example, package `foo.bar` is expanded to `foo/bar` and `foo/bar/`.
The latter allows find package `foo.bar` in a module called `foo.bar`,
and not `foo`.

Fixes #2500
Fixes #2600
Fixes #2612
sormuras added a commit that referenced this issue May 12, 2021
Fix `getRootUrisForPackage()` in class `ClasspathScanner` by looking for two
"wordings" of a package name.

For example, package `foo.bar` is expanded to `foo/bar` and `foo/bar/`.
The latter allows find package `foo.bar` in a module called `foo.bar`,
and not `foo`.
This commit also ensures, that there's no regression (compared to #2531)
by launching test runs using the standalone artifact with `--select-package`
and `--scan-class-path`.

Fixes #2500
Fixes #2600
Fixes #2612
marcphilipp pushed a commit that referenced this issue May 13, 2021
Fix `getRootUrisForPackage()` in class `ClasspathScanner` by looking for two
"wordings" of a package name.

For example, package `foo.bar` is expanded to `foo/bar` and `foo/bar/`.
The latter allows find package `foo.bar` in a module called `foo.bar`,
and not `foo`.
This commit also ensures, that there's no regression (compared to #2531)
by launching test runs using the standalone artifact with `--select-package`
and `--scan-class-path`.

Fixes #2500
Fixes #2600
Fixes #2612
@sormuras
Copy link
Member

runningcode pushed a commit to runningcode/junit5 that referenced this issue Feb 15, 2023
Fix `getRootUrisForPackage()` in class `ClasspathScanner` by looking for two
"wordings" of a package name.

For example, package `foo.bar` is expanded to `foo/bar` and `foo/bar/`.
The latter allows find package `foo.bar` in a module called `foo.bar`,
and not `foo`.
This commit also ensures, that there's no regression (compared to junit-team#2531)
by launching test runs using the standalone artifact with `--select-package`
and `--scan-class-path`.

Fixes junit-team#2500
Fixes junit-team#2600
Fixes junit-team#2612
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants