Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven don';t执行junit测试_Maven_Junit - Fatal编程技术网

Maven don';t执行junit测试

Maven don';t执行junit测试,maven,junit,Maven,Junit,我正在尝试测试此项目: 但是maven说: $ mvn clean install WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method jav

我正在尝试测试此项目: 但是maven说:

$ mvn clean install    
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] jenktest
[INFO] hello
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building jenktest 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ jenktest ---
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ jenktest ---
[INFO] Installing /documenti/deglans/Programs/IdeaProjects/jenktest/pom.xml to /home/deglans/.m2/repository/io/github/deglans/jenktest/0.0.1-SNAPSHOT/jenktest-0.0.1-SNAPSHOT.pom
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building hello 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hello ---
[INFO] Deleting /documenti/deglans/Programs/IdeaProjects/jenktest/hello/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ hello ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /documenti/deglans/Programs/IdeaProjects/jenktest/hello/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hello ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /documenti/deglans/Programs/IdeaProjects/jenktest/hello/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ hello ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /documenti/deglans/Programs/IdeaProjects/jenktest/hello/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hello ---
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ hello ---
[INFO] Building jar: /documenti/deglans/Programs/IdeaProjects/jenktest/hello/target/hello-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ hello ---
[INFO] Installing /documenti/deglans/Programs/IdeaProjects/jenktest/hello/target/hello-0.0.1-SNAPSHOT.jar to /home/deglans/.m2/repository/io/github/deglans/hello/0.0.1-SNAPSHOT/hello-0.0.1-SNAPSHOT.jar
[INFO] Installing /documenti/deglans/Programs/IdeaProjects/jenktest/hello/pom.xml to /home/deglans/.m2/repository/io/github/deglans/hello/0.0.1-SNAPSHOT/hello-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] jenktest ........................................... SUCCESS [  0.449 s]
[INFO] hello .............................................. SUCCESS [  1.715 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.360 s
[INFO] Finished at: 2017-12-16T11:41:59+01:00
[INFO] Final Memory: 14M/48M
[INFO] ------------------------------------------------------------------------
警告是什么?为什么maven完全跳过了测试阶段

这项工作的最终目的是测试电子邮件jenkins功能,但现在我被这个问题阻止了

谢谢

总结 您需要将
GreetingTests.java
重命名为
GreetingTest.java
,或者更新
maven-surefire插件。更新surefire插件可以为用户提供更好的模式。您可以在项目的父POM
/POM.xml
中声明它:

<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <!-- ... -->

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.20.1</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>
您需要将测试重命名为
GreetingTests.java
GreetingTest.java
。因为
surefire插件:2.12.4
无法识别模式
*Tests.java
,如文档所述:

默认情况下,插件将自动包含具有以下通配符模式的所有测试类:

  • “***/Test*.java”
    -包括其所有子目录和所有java 以“Test”开头的文件名

  • “***Test.java”
    -包括其所有子目录和所有java 以“Test”结尾的文件名

  • “***TestCase.java”
    -包括其所有子目录和所有java 以“TestCase”结尾的文件名


使用选项
-X
运行Maven以查看调试消息。出现警告是因为库尚未升级到Java 9
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hello ---