我在Eclipse中创建了一个新的Maven项目。当我尝试运行任何使用Test注释的方法时,其中的内容不会被执行。我检查了所有构建路径等但没有发现任何错误。我删除并重新创建了该项目。关闭并重新打开Eclipse。下面是代码和控制台日志。控制台日志中也没有错误。如果需要任何其他信息,请告诉我
不确定我做错了什么,但几小时后工作正常
注意:我正在使用TestNG来运行测试
代码:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building framework 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ framework ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ framework ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ framework ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ framework ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ framework ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.218 s
[INFO] Finished at: 2018-04-01T13:01:26+05:30
[INFO] Final Memory: 7M/19M
[INFO] ------------------------------------------------------------------------
控制台日志:
$sql = "INSERT INTO coinflip (gameid, hash_sha1, hash_original, created_by)
VALUES ('$cycle', '$hash', '$CharTick', '$created_by')";
答案 0 :(得分:0)
在对代码进行以下更改
后,它确实适用于我package testPackage;
import org.junit.Test;
public class testClass {
@Test
public void testMethod() {
System.out.println("test");
}
}
下面是pom中使用的依赖
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
答案 1 :(得分:0)
问题已解决。我将Test类的名称从框架更改为TestClass,它开始工作。我读到某处(不记得),TestNG类名应包含“Test”,以便将其标识为TestNG Test类。