简体   繁体   中英

Mvn build success but no tests are executed

I have almost no idea why this could be happening but when I run

mvn clean install

or

#Builds with class instrumentation (code coverage)
mvn cobertura:cobertura

Everything was working just fine until I made a slight change which was to my pom.xml file, so it could contain dependencies classes I was using in my code rather than literally importing several classes into my project.

This is the terminal/console out I get when I run maven:

SDGL12025ba66:TestCompletenessCompilerRuntime mosawi$ mvn cobertura:cobertura
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building TestCompletenessCompilerRuntime 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> cobertura-maven-plugin:2.7:cobertura (default-cli) > [cobertura]test @ TestCompletenessCompilerRuntime >>>
Downloading: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/repositories/public/org/slf4j/slf4j-log4j12/1.6.2/slf4j-log4j12-1.6.2.pom
Downloaded: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/repositories/public/org/slf4j/slf4j-log4j12/1.6.2/slf4j-log4j12-1.6.2.pom (2 KB at 14.2 KB/sec)
Downloading: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/groups/public/com/generalatomics/ctg/tla/models/model-data-source/2015.1.11-SNAPSHOT/maven-metadata.xml
Downloaded: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/groups/public/com/generalatomics/ctg/tla/models/model-data-source/2015.1.11-SNAPSHOT/maven-metadata.xml (804 B at 3.1 KB/sec)
Downloading: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/groups/public/com/generalatomics/ctg/tla/compilers/decision-map-common/2015.1.11-SNAPSHOT/maven-metadata.xml
Downloaded: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/groups/public/com/generalatomics/ctg/tla/compilers/decision-map-common/2015.1.11-SNAPSHOT/maven-metadata.xml (809 B at 3.6 KB/sec)
Downloading: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/groups/public/com/generalatomics/ctg/tla/models/decision-table-model/2015.1.11-SNAPSHOT/maven-metadata.xml
Downloaded: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/groups/public/com/generalatomics/ctg/tla/models/decision-table-model/2015.1.11-SNAPSHOT/maven-metadata.xml (807 B at 1.2 KB/sec)
Downloading: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/groups/public/com/generalatomics/ctg/tla/compilers/mapping-maven-plugin/2015.1.11-SNAPSHOT/maven-metadata.xml
Downloaded: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/groups/public/com/generalatomics/ctg/tla/compilers/mapping-maven-plugin/2015.1.11-SNAPSHOT/maven-metadata.xml (810 B at 3.7 KB/sec)
Downloading: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/groups/public/com/generalatomics/ctg/tla/models/calc-graph-model/2015.1.11-SNAPSHOT/maven-metadata.xml
Downloaded: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/groups/public/com/generalatomics/ctg/tla/models/calc-graph-model/2015.1.11-SNAPSHOT/maven-metadata.xml (803 B at 2.1 KB/sec)
Downloading: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/repositories/public/org/slf4j/slf4j-log4j12/1.6.2/slf4j-log4j12-1.6.2.jar
Downloaded: http://ctg-cache-repo.corp.generalatomics.net/nexus/content/repositories/public/org/slf4j/slf4j-log4j12/1.6.2/slf4j-log4j12-1.6.2.jar (10 KB at 380.9 KB/sec)
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ TestCompletenessCompilerRuntime ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ TestCompletenessCompilerRuntime ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- cobertura-maven-plugin:2.7:instrument (default-cli) @ TestCompletenessCompilerRuntime ---
[INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[INFO] Cobertura: Loaded information on 13 classes.
[INFO] Cobertura: Saved information on 13 classes.
[INFO] Cobertura: Saved information on 13 classes.

[ERROR] SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/mosawi/.m2/repository/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/mosawi/.m2/repository/org/slf4j/slf4j-log4j12/1.6.2/slf4j-log4j12-1.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

[INFO] Instrumentation was successful.
[INFO] NOT adding cobertura ser file to attached artifacts list.
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ TestCompletenessCompilerRuntime ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 832 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ TestCompletenessCompilerRuntime ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 7 source files to /Users/mosawi/Perforce/mosawi_newTPS/QE/automation/TestCompletenessCompilerRuntime/target/test-classes
[INFO] /Users/mosawi/Perforce/mosawi_newTPS/QE/automation/TestCompletenessCompilerRuntime/src/test/java/com/generalatomics/ctg/tla/compilers/CompilerTest.java: /Users/mosawi/Perforce/mosawi_newTPS/QE/automation/TestCompletenessCompilerRuntime/src/test/java/com/generalatomics/ctg/tla/compilers/CompilerTest.java uses or overrides a deprecated API.
[INFO] /Users/mosawi/Perforce/mosawi_newTPS/QE/automation/TestCompletenessCompilerRuntime/src/test/java/com/generalatomics/ctg/tla/compilers/CompilerTest.java: Recompile with -Xlint:deprecation for details.
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ TestCompletenessCompilerRuntime ---
[INFO] Surefire report directory: /Users/mosawi/Perforce/mosawi_newTPS/QE/automation/TestCompletenessCompilerRuntime/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestSuite
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@7c40bc88
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.32 sec

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] <<< cobertura-maven-plugin:2.7:cobertura (default-cli) < [cobertura]test @ TestCompletenessCompilerRuntime <<<
[INFO] 
[INFO] --- cobertura-maven-plugin:2.7:cobertura (default-cli) @ TestCompletenessCompilerRuntime ---
[INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[INFO] Cobertura: Loaded information on 13 classes.
Report time: 249ms

[INFO] Cobertura Report generation was successful.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.421 s
[INFO] Finished at: 2015-08-05T14:06:28-07:00
[INFO] Final Memory: 28M/438M
[INFO] ------------------------------------------------------------------------
SDGL12025ba66:TestCompletenessCompilerRuntime mosawi$ 

I really don't understand what could be causing this? Any help would be much appreciated. Thanks

That error you see for slf4j should be fine. I've seen that before, so I am certain thats not the culprit of what is happening here

Edit: I'm noticing that my test seem to be executing with TestNG but I'm using JUnit:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestSuite
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@7c40bc88
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.32 sec

Why would mvn clean install try to build or run my tests with TestNG rather than Junit? Could it be the new dependencies I added?

Just to point. Make sure your test classes are in a test folder(package), and class name should be Test*, *Test, *TestCase.

Surefire has a mechanism to figure out whether to run JUnit or TestNG. Probably something in your dependencies/code is making surefire try to use TestNG.

You can disable the automatic detection and force a test provider (see the selecting providers in the documentation). Just for future reference, you need to configure surefire in the following way (taken from the previous link). This will force Surefire to use a Junit 4.7 compatible provider.

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.18.1</version>
    <dependencies>
      <dependency>
        <groupId>org.apache.maven.surefire</groupId>
        <artifactId>surefire-junit47</artifactId>
        <version>2.18.1</version>
      </dependency>
    </dependencies>
  </plugin>

I've seen this issue once before, about 6-7 years ago, and I cannot remember what I did to fix it to make Surefire detect the test provider properly, but I do remember debbuging the surefire plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM