gpt4 book ai didi

java - mvn 构建成功但未执行任何测试

转载 作者:行者123 更新时间:2023-12-01 18:12:35 32 4
gpt4 key购买 nike

我几乎不知道为什么会发生这种情况,但是当我运行时

mvn clean install

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

一切都工作得很好,直到我对我的 pom.xml 文件做了一个小小的更改,这样它就可以包含我在代码中使用的依赖项类,而不是逐字导入多个类到我的项目中。

这是我运行 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$

我真的不明白这是什么原因造成的?任何帮助将非常感激。谢谢

您在 slf4j 中看到的错误应该没问题。我以前见过这种情况,所以我确信这不是这里发生的事情的罪魁祸首

编辑:我注意到我的测试似乎是使用 TestNG 执行的,但我使用的是 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

为什么 mvn clean install 会尝试使用 TestNG 而不是 Junit 来构建或运行我的测试?难道是我添加了新的依赖项?

最佳答案

只是为了指出一点。确保您的测试类位于测试文件夹(包)中,类名称应为 Test*、*Test、*TestCase。

关于java - mvn 构建成功但未执行任何测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31842959/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com