[
https://issues.apache.org/jira/browse/SUREFIRE-1621?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16752302#comment-16752302
]
Alex Chachanashvili commented on SUREFIRE-1621:
-----------------------------------------------
{{I was trying different things, but this is a sample maven project I created,
it has 1 java file which doesn't do much and a test which is supposed to always
fail. Works fine inside IntelliJ but running `mvn test` finds nothing. I
have attached the entire sample project: [^MavenJUnit5Test.tar.gz]}}
{{I am using jdk 11 on OsX}}
{code:java}
openjdk 11.0.2 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.2+7)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+7, mixed mode)
{code}
Running the attached project with mvn test:
{code:java}
~/Code/MavenJUnit5Test ᐅ mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< MavenJunit5Test:achacha.test.maven >-----------------
[INFO] Building achacha.test.maven 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
achacha.test.maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @
achacha.test.maven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @
achacha.test.maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory
/Users/achacha/Code/MavenJUnit5Test/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
achacha.test.maven ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to
/Users/achacha/Code/MavenJUnit5Test/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @
achacha.test.maven ---
[INFO] Surefire report directory:
/Users/achacha/Code/MavenJUnit5Test/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.670 s
[INFO] Finished at: 2019-01-25T08:18:01-06:00
[INFO] ------------------------------------------------------------------------
~/Code/MavenJUnit5Test ᐅ mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< MavenJunit5Test:achacha.test.maven >-----------------
[INFO] Building achacha.test.maven 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
achacha.test.maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @
achacha.test.maven ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to
/Users/achacha/Code/MavenJUnit5Test/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @
achacha.test.maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory
/Users/achacha/Code/MavenJUnit5Test/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
achacha.test.maven ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to
/Users/achacha/Code/MavenJUnit5Test/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @
achacha.test.maven ---
[INFO] Surefire report directory:
/Users/achacha/Code/MavenJUnit5Test/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.690 s
[INFO] Finished at: 2019-01-25T08:22:57-06:00
[INFO] ------------------------------------------------------------------------
{code}
> package-private class/method supported in JUnit5 is not executed
> ----------------------------------------------------------------
>
> Key: SUREFIRE-1621
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1621
> Project: Maven Surefire
> Issue Type: Bug
> Components: JUnit 5.x support
> Affects Versions: 3.0.0-M3
> Environment: Java openJDK11, Maven 3.6.0
> Reporter: Alex Chachanashvili
> Priority: Major
> Attachments: MavenJUnit5Test.tar.gz
>
>
> Test classes/methods have to be made pubic in order for maven/surefire to
> execute them.
>
> Following will not execute (DebugTest.java) with surefire but will work with
> IntelliJ, eclipse, Gradle, etc that support JUnit5:
>
> {code:java}
> class DebugTest {
> @Test
> void failAlways() { assertTrue(false); }
> }
> {code}
>
> However changing it to following will work with Surefire but cause IDEs to
> flag public scope that can be changed to package-private:
>
> {code:java}
> public class DebugTest {
> @Test
> public void failAlways() { assertTrue(false); }
> }
> {code}
>
> JUnit 5 is supposed to support package-private declaration for test classes
> and test methods and IDEs like IntelliJ and eclipse are suggesting this,
> creating issues for people writing new tests that are not aware of the
> surefire anomaly. Also automatic code cleanup in some IDEs are changing the
> tests to be package-private and causing them to no longer run.
>
> Package-private tests are running correctly inside the IDEs and via Gradle,
> but being skipped with Maven+Surefire.
>
> from POM (basically a simple java project)
> {code:java}
> <build>
> <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <version>3.0.0-M3</version>
> </plugin>
> </plugins>
> </build>
> {code}
>
> and in dependencies:
> {code:java}
> <dependencies>
> ...
> <dependency>
> <groupId>org.junit.jupiter</groupId>
> <artifactId>junit-jupiter-api</artifactId>
> <version>5.3.2</version>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <version>3.0.0-M3</version>
> <scope>test</scope>
> </dependency>
> </dependencies>
> {code}
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)