【问题标题】:TestNG-functionality not recognized by IntellijIntellij 无法识别 TestNG 功能
【发布时间】:2016-07-12 07:32:53
【问题描述】:

我正在尝试使用 TestNG 来测试我的 Java 代码。 TestNG-plugin安装在IntelliJ中,依赖:

<dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.10</version>
</dependency>

已添加到 Maven。但是,当我在类中编写“@Test”时,IntelliJ 会给出错误消息:“无法解析符号 'Test'。

导入 org.testng.annotations.Test 也无法识别。似乎 Intellij 忽略了 Maven 依赖项。

这是项目结构和错误:

我是否应该对 TestNG 做更多的事情,而不是仅仅添加 Maven 依赖项?

【问题讨论】:

  • mvn clean install
  • 尝试右击signing-spring,甚至dc16-signing,然后选择maven -> reimport
  • 除上述之外,您在哪个 pom 中添加了 Test-NG 依赖项?附言您还应该在其定义中添加<scope>test</scope>
  • 感谢 cmets,问题已解决。只需要全新安装 :) 但我也会记住其他提示

标签: java maven intellij-idea


【解决方案1】:
  1. 运行mvn clean

  2. testngscope设置为test,即:

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.12</version>
        <scope>test</scope>
    </dependency>
    
  3. 运行mvn install

【讨论】:

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