从 Eclipse 运行 TestNG testng.xml 测试

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3679766/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 19:37:28  来源:igfitidea点击:

Running TestNG testng.xml tests from Eclipse

eclipseclasspathtestng

提问by zihaoyu

I have some packages

我有一些包裹

com.company.testing.module1
com.company.testing.module2
com.company.testing.module3

I also have some classes that have TestNG annotations in

我也有一些带有 TestNG 注释的类

com.company.testing.tests

Now I put testng.xml in

现在我把 testng.xml 放在

com.company.testing

The XML file looks like

XML 文件看起来像

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Foo">
    <test name="Bar">
        <package>
            <package name="com.company.testing.tests" />
        </package>
    </test>
</suite>

How do I run the suite from Eclipse? What Run Configuration should I do?

如何从 Eclipse 运行套件?我应该做什么运行配置?

回答by Cedric Beust

Install the TestNG plug-inand when you're done, you can just right click on your XML file and "Run as/Debug as... TestNG.

安装TestNG 插件,完成后,您只需右键单击您的 XML 文件,然后“Run as/Debug as... TestNG.

回答by Woot4Moo

You'll need the testng plugin. Then its just a matter of running the testng task. See the docsfor further details.

您将需要 testng 插件。那么它只是运行 testng 任务的问题。有关更多详细信息,请参阅文档

回答by SDV

To run your test through testNG.xmlgoto the class file right click and select Run as >>run configuratins. Select Suiteand browse your testNG.xml(default in eclipse - testng-customsuite.xml) and RUN.

要通过testNG.xml转到类文件运行您的测试,请右键单击并选择 Run as >> run configuratins。选择Suite并浏览您的testNG.xml(eclipse 中的默认设置 - testng-customsuite.xml)和 RUN。