【发布时间】:2015-12-21 23:24:25
【问题描述】:
由于某种原因我不知道,有时,当我创建一个新的测试项目(我使用 IntelliJ + Maven 模块)时,我使用相同的 pom 文件和一些当前在另一个项目中工作的插件,但是当我运行命令行
mvn test
它不运行我编写的 JUnit 测试方法。而且我不知道出了什么问题,它说:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building n26 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ n26 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ n26 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ n26 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Automation\NewHomePage\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ n26 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\Automation\NewHomePage\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ n26 ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.713 s
[INFO] Finished at: 2015-09-24T13:02:50+02:00
[INFO] Final Memory: 19M/306M
[INFO] ------------------------------------------------------------------------
通常,它会在之后执行测试,但有时会在这里停止。
【问题讨论】:
-
你的测试方法有注解
@Test吗? -
测试由 surefire-plugin 执行,它有一个将解释为测试类的文件的命名约定:maven.apache.org/surefire/maven-surefire-plugin/… - 你的测试类与它们匹配吗?否则你需要配置它。
-
@Tunaki,是的,我的测试有注释“@Test”
标签: maven intellij-idea junit automation pom.xml