【问题标题】:IntelliJ- Adding testNG maven dependency brings junitIntelliJ-添加testNG maven依赖带来junit
【发布时间】:2020-12-01 21:29:51
【问题描述】:

当我添加 testng 依赖项时,在 POM 文件中,我从来没有得到导入 testng 的选项。我只得到Junit。我没有 Junit 作为依赖项。

  <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.3.0</version>
            <scope>test</scope>
        </dependency>

当我研究这个问题时,我发现有人在下面的链接中遇到了类似的问题。但是我没有看到解决方案。任何人都知道如何解决这种情况?我想使用 TestNG,以便我可以使用 testNG.xml 来运行测试。

https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003437720-Why-Intellij-doesn-t-import-the-TestNG-maven-dependency-automatically-

提前致谢

【问题讨论】:

    标签: intellij-idea testng maven-dependency


    【解决方案1】:

    它对我有用。确保您已将正确 Maven 模块的依赖项添加到依赖项部分。在此之后确保您在 Maven 工具窗口中重新导入了项目:

    【讨论】:

      【解决方案2】:

      最初,当我从https://mvnrepository.com/artifact/org.testng/testng/7.3.0 复制工件并将代码粘贴到我的 IntelliJ 时,我遇到了同样的问题,它显示了错误,一旦我从磁盘重新加载(右键单击项目,它将显示该选项)它正在显示屏幕右侧的刷新选项,一旦我刷新它,错误就解决了。

      【讨论】:

        【解决方案3】:

        我尝试了 Intellij 右上角显示的重新加载选项,但对我不起作用。然后我右键单击项目 > maven > 重新加载项目。

        在此之后,所有 maven 依赖项都已解决。

        【讨论】:

        • 这对我有用。谢谢。
        猜你喜欢
        • 1970-01-01
        • 2016-06-29
        • 2017-03-24
        • 2020-01-30
        • 2016-03-31
        • 1970-01-01
        • 1970-01-01
        • 2018-05-07
        • 1970-01-01
        相关资源
        最近更新 更多