[
https://issues.apache.org/jira/browse/SUREFIRE-1676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16885517#comment-16885517
]
Tibor Digana commented on SUREFIRE-1676:
----------------------------------------
>>It goes right back to running the parameters, without running the methods.
I do not understand what parameters you mean?
Btw, do you have pure test classes which do not have {{@RunWith}} annotation on
the class?
You have parameterized tests. These are documented as well and I remember that
parameterized tests have brackes in JUnit Description and these must be
respected. Long time ago when I maintained this feature but the documentation
talks about them.
> surefire-junit47 is not running JUnit4 tests
> --------------------------------------------
>
> Key: SUREFIRE-1676
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1676
> Project: Maven Surefire
> Issue Type: Bug
> Components: Maven Surefire Plugin
> Affects Versions: 3.0.0-M3
> Environment: Windows 10 and Centos 7 behave the same.
> java 1.8.161
> Reporter: Bobby Erwin
> Priority: Major
> Attachments: mvn -X output2.txt, mvn-dependency-tree.log
>
>
> In a maven project with lots of JUnit 4 tests, surefire-junit47 is not
> executing the tests.
> There are no testng tests in this project, and there is no testng in the pom.
> But this project has a dependency on another project that does have testng in
> the pom. You can see it import testng in the mvn -X output, attached.
> With testng on the classpath, surefire tries to execute tests through testng.
> So we're configuring our test execution based on this page:
> https://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html
> For reference sake, here is the documentation I'm working
> from:[https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html]
> Curiously enough, it appears to find the test classes, but doesn't execute
> the methods. That is, if processes all the static fields and @Parameterized
> methods, but it doesn't execute any @Test methods.
> Here are a couple of pom configurations that show the problem.
> Given this test class organization:
> {code:java}
> - src/main/test/
> - com.mycomp.qc.core.account
> - CopyAccountTests.java
> - CreateAccountTests.java
> - DeleteAccountTests.java
> - ListAccountTests.java
> - ReadAccountTests.java
> - UpdateAccountTests.java
> - com.mycomp.qc.core.product
> - CopyProductTests.java
> - CreateProductTests.java
> - DeleteProductTests.java
> - ListProductTests.java
> - ReadProductTests.java
> - UpdateProductTests.java
> - ..... and 300 more packages .....{code}
>
> And given this test class structure:
> {code:java}
> package com.mycomp.qc.core.account;
> import org.junit.Assert;
> import org.junit.Test;
> .... and more ....
> public class CopyAccountTests {
> @Test
> public void copyAccount1() {
> Assert.assertTrue("pass", true);
> }
> @Test
> public void copyAccount2() {
> Assert.assertTrue("fail", false);
> }
> .... and more ....
> }{code}
>
> *pom config 1: Specifically include Account tests, by pattern*
> Runs all the Account tests, just as the documentation indicates.
> {code:xml}
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <version>${surefire.version}</version>
> <dependencies>
> <dependency>
> <groupId>org.apache.maven.surefire</groupId>
> <artifactId>surefire-junit47</artifactId>
> <version>${surefire.version}</version>
> </dependency>
> </dependencies>
> <configuration>
> <testFailureIgnore>true</testFailureIgnore>
> <includes>
> <include>*Account*</include>
> </includes>
> <threadCount>1</threadCount>
> </configuration>
> <executions>
> <execution>
> <id>default-test</id>
> <phase>test</phase>
> <goals>
> <goal>test</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> {code}
> *pom config 2: Specifically include Account tests, by pattern*
> Runs all the Account and Product tests, just as the documentation indicates.
> {code:xml}
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <version>${surefire.version}</version>
> <dependencies>
> <dependency>
> <groupId>org.apache.maven.surefire</groupId>
> <artifactId>surefire-junit47</artifactId>
> <version>${surefire.version}</version>
> </dependency>
> </dependencies>
> <configuration>
> <testFailureIgnore>true</testFailureIgnore>
> <includes>
> <include>*Account*</include>
> <include>*Product*</include>
> </includes>
> <threadCount>1</threadCount>
> </configuration>
> <executions>
> <execution>
> <id>default-test</id>
> <phase>test</phase>
> <goals>
> <goal>test</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> {code}
> *pom config 3: Include all tests, based on default surefire*
> Finds and initializes test classes, but does not execute any @Test methods.
> {code:xml}
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <version>${surefire.version}</version>
> <dependencies>
> <dependency>
> <groupId>org.apache.maven.surefire</groupId>
> <artifactId>surefire-junit47</artifactId>
> <version>${surefire.version}</version>
> </dependency>
> </dependencies>
> <configuration>
> <testFailureIgnore>true</testFailureIgnore>
> <threadCount>1</threadCount>
> </configuration>
> <executions>
> <execution>
> <id>default-test</id>
> <phase>test</phase>
> <goals>
> <goal>test</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> {code}
> *pom config 4: Include all tests, by pattern*
> Finds and initializes test classes, but does not execute any @Test methods.
> {code:xml}
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-surefire-plugin</artifactId>
> <version>${surefire.version}</version>
> <dependencies>
> <dependency>
> <groupId>org.apache.maven.surefire</groupId>
> <artifactId>surefire-junit47</artifactId>
> <version>${surefire.version}</version>
> </dependency>
> </dependencies>
> <configuration>
> <testFailureIgnore>true</testFailureIgnore>
> <includes>
> <include>*Test*</include>
> </includes>
> <threadCount>1</threadCount>
> </configuration>
> <executions>
> <execution>
> <id>default-test</id>
> <phase>test</phase>
> <goals>
> <goal>test</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> {code}
> *What I've tried:*
> # Obviously, from the examples, I've tried different include patterns in the
> pom. See the results outlined above.
> # Configured a new project, with all the same imports and just a few small
> tests. All the include patterns above behaved as outlined in the
> documentation.
> # Switched the surefire provider to surefire-junit4. This, in fact, executed
> all tests, but we ran into other problems.
> # Ran mvn -X, mainly to look for testng problems, based on this answer:
> Surefire is not picking up Junit 4 tests.
> # mvn -X showed that the default maven-resources-plugin pulls in junit 3.8.x,
> which the doc says might cause problems. Updated resources to 3.1.0, but it
> didn't fix my problem.
> *mvn -X output*
> attached
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)