【问题标题】:Build Success | Not Getting any error in Maven Project in Eclipse but nothing is happening建立成功 |在 Eclipse 的 Maven 项目中没有出现任何错误,但没有发生任何事情
【发布时间】:2018-09-10 18:22:38
【问题描述】:

我在 Eclipse 中创建了一个新的 Maven 项目。当我尝试运行使用 Test 注释的任何方法时,其中的内容不会被执行。我检查了所有构建路径等,但没有发现任何问题。我删除并重新创建了项目。关闭并重新打开 Eclipse。下面是代码和控制台日志。控制台日志中也没有错误。如果需要任何其他信息,请告诉我

不知道我做错了什么,但几个小时前它工作正常

注意:我正在使用 TestNG 运行测试

代码:

package testPackage;

import org.testng.annotations.Test;

public class testClass {


    @Test
    public void testMethod() {
        System.out.println("test");
    }

}

控制台日志:

[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] ------------------------------------------------------------------------

【问题讨论】:

    标签: java eclipse maven build


    【解决方案1】:

    在对代码进行以下更改后,它确实为我运行了

    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>
    

    【讨论】:

    • 我忘了(在正文中)我使用的是 TestNG 而不是 JUnit。我会修改问题。
    【解决方案2】:

    问题已解决。我将测试类的名称从框架更改为 TestClass 并开始工作。我在某处读到(虽然不记得)TestNG 类名应该包含“Test”,以便被它识别为 TestNG 测试类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-07
      • 1970-01-01
      相关资源
      最近更新 更多