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

[SUREFIRE-2032] Fix test count when using @Disabled at class level #564

Merged
merged 2 commits into from
Dec 23, 2022

Conversation

gnodet
Copy link
Contributor

@gnodet gnodet commented Sep 19, 2022

@michael-o
Copy link
Member

Let me try this...

@michael-o
Copy link
Member

michael-o commented Oct 11, 2022

I have now built and installed M8-SNAPSHOT, but cannot confirm that it is fixed:

osipovmi@deblndw011x:~/var/Projekte/mit (master *=)
$ cat core-it-suite/target/surefire-reports/TEST-org.apache.maven.it.MavenITmng4629NoPomValidationErrorUponMissingSystemDepTest.xml
...
 69   <testcase name="" classname="org.apache.maven.it.MavenITmng4633DualCompilerExecutionsWeaveModeTest" time="0">
 70     <skipped message="class org.apache.maven.it.MavenITmng4633DualCompilerExecutionsWeaveModeTest is @Disabled"/>
 71   </testcase>
...

with

osipovmi@deblndw011x:~/var/Projekte/mit (master *=)
$ git diff
diff --git a/pom.xml b/pom.xml
index de8fc4ba4..c8a1477aa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -141,7 +141,7 @@ under the License.
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-surefire-plugin</artifactId>
-          <version>3.0.0-M7</version>
+          <version>3.0.0-M8-SNAPSHOT</version>
           <configuration>
             <environmentVariables>
               <JENKINS_MAVEN_AGENT_DISABLED>true</JENKINS_MAVEN_AGENT_DISABLED>
diff --git a/run-its.sh b/run-its.sh
index c438cbb5b..b0c0744ab 100755
--- a/run-its.sh
+++ b/run-its.sh
@@ -25,7 +25,7 @@
 # For Jdk 7 use with -Dhttps.protocols=TLSv1.2
 # mvn clean install -Prun-its,embedded -Dmaven.repo.local=`pwd`/repo -Dhttps.protocols=TLSv1.2

-mvn clean install -Prun-its,embedded -Dmaven.repo.local=`pwd`/repo
+mvn clean install -Prun-its,embedded -Dmaven.repo.local=`pwd`/repo -DmavenDistro=/var/osipovmi/Projekte/maven/apache-maven/target/apache-maven-4.0.0-alpha-1-SNAPSHOT-bin.zip

 # If behind a proxy try this

@andpab
Copy link
Contributor

andpab commented Dec 22, 2022

I can confirm that this PR fixes the issue for the setup of the original reporter at least - although I had to modify the setup slightly, making the abstract class an inner class, making the implementations non-static and adding @Nested:

package surefire2032;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

public class Test1 {

  @Tag("red")
  @Nested
  public class RedTest extends TagTest {
  }

  @Disabled
  @Tag("orange")
  @Nested
  public class OrangeTest extends TagTest {
  }
  
  abstract class TagTest {

      @Test
      public void test1() {
        // Do Nothing
      }

      @Test
      public void test2() {
        // Do Nothing
      }
 
  }
}

Console output:

[INFO] Running surefire2032.Test1
[INFO] Running surefire2032.Test1$OrangeTest
[WARNING] Tests run: 2, Failures: 0, Errors: 0, Skipped: 2, Time elapsed: 0.008 s - in surefire2032.Test1$OrangeTest
[INFO] Running surefire2032.Test1$RedTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 s - in surefire2032.Test1$RedTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.042 s - in surefire2032.Test1
[INFO]
[INFO] Results:
[INFO]
[WARNING] Tests run: 4, Failures: 0, Errors: 0, Skipped: 2

XML output:

$ cat target/surefire-reports/TEST-surefire2032.Test1\$OrangeTest.xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="surefire2032.Test1$OrangeTest" time="0.008" tests="2" errors="0" skipped="2" failures="0">
  <properties/>
  <testcase name="test1" classname="surefire2032.Test1$OrangeTest" time="0">
    <skipped message="class surefire2032.Test1$OrangeTest is @Disabled"/>
  </testcase>
  <testcase name="test2" classname="surefire2032.Test1$OrangeTest" time="0">
    <skipped message="class surefire2032.Test1$OrangeTest is @Disabled"/>
  </testcase>
</testsuite>

$ cat target/surefire-reports/TEST-surefire2032.Test1\$RedTest.xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="surefire2032.Test1$RedTest" time="0.023" tests="2" errors="0" skipped="0" failures="0">
  <properties>
    ...
  </properties>
  <testcase name="test1" classname="surefire2032.Test1$RedTest" time="0.012"/>
  <testcase name="test2" classname="surefire2032.Test1$RedTest" time="0.002"/>
</testsuite>

$ cat target/surefire-reports/TEST-surefire2032.Test1.xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="surefire2032.Test1" time="0.046" tests="0" errors="0" skipped="0" failures="0">
  <properties>
    ...
  </properties>
</testsuite>

@gnodet gnodet merged commit 4545bca into apache:master Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants