简体   繁体   English

如何使用XML文件使用testNG多次运行测试?

[英]How can i run a Test multiple times using testNG using XML file?

I've 3 @Test methods say, methodA, methodB and methodC. 我有3个@Test方法,例如methodA,methodB和methodC。 All the 3 methods are used to fill a Form one by one that takes input from CSV file. 所有这三种方法都用于一张一张地填写表格,该表格从CSV文件中获取输入。 My XML file looks like below... 我的XML文件如下所示...

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Fill Forms">
    <test name="Fill multiple times">
        <classes>
            <class name="com.class"/>
                <methods>
                    <include name='methodA'/>
                    <include name='methodB'/>
                    <include name='methodC'/>
                </methods>
            </class>
        </classes>
    </test>
</suite>

I want to run the Test 'Fill Multiple Times' multiple times. 我想多次运行“多次填充”测试。

Kindly suggest me an idea... 请给我一个主意...

If each method is interacting with the same elements and just passing different inputs, try parameterizing your tests with one of the approaches available in TestNG. 如果每种方法都与相同元素交互并且只是传递不同的输入,请尝试使用TestNG中可用的方法之一对测试进行参数化。

http://testng.org/doc/documentation-main.html#parameters http://testng.org/doc/documentation-main.html#parameters

XML Parameters will work well, but this will result in a more verbose Suite XML file. XML参数将很好地工作,但这将导致更详细的Suite XML文件。

My recommendation, assuming the above condition is true, would be to use a DataProvider with your test. 假设上述条件成立,我的建议是在测试中使用DataProvider。 This way, you only need to write the test method once and the DataProvider will iterate over the test for each data set you define. 这样,您只需要编写一次测试方法,DataProvider就会为您定义的每个数据集遍​​历测试。

EDIT: Since your test isn't able to be parameterized... If you're simply looking to repeat the test methods a number of times, you could either repeat the <test> node on the XML as many times as you wish to repeat the execution. 编辑:由于无法对测试进行参数化设置...如果您只是想重复测试方法多次,则可以根据需要将XML上的<test>节点重复多次。重复执行。 If you wish to keep your XML from getting too verbose, you could look into creating a test case factory . 如果您希望避免XML变得过于冗长,可以考虑创建一个测试用例工厂

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以使用TestNG XML文件使用某些选定的方法多次运行1个测试组? - Is there a way to run 1 test-group multiple times with some selected methods using TestNG XML file? 我如何使用testng发送多个测试数据到以下 - How can i send multiple test data using testng in to following 如何使用org.testng.TestNG将参数输入此测试运行中? - How can I get parameters into this test run using org.testng.TestNG? 如何使用 testng.xml 运行测试文件 - How to run the test files by using the testng.xml 使用testng.xml使用maven运行单个TestNG测试 - Run single TestNG test with maven by using testng.xml 如何使用页面工厂在testng中运行多个测试类? - How to run multiple test classes in testng using page factory? 如何使用Selenium和TestNG对多个站点运行一个测试 - How to run one test against multiple sites using Selenium and TestNG Maven / TestNG / Selenium-我可以在一个testng.xml中设置多个测试套件,并在不同的时间运行不同的套件吗? - Maven/TestNG/Selenium - Can I set up multiple tests suites in one testng.xml and run different ones at different times? 如何基于内部逻辑多次运行testNG测试? - How do I run a testNG test multiple times, based on an internal logic? 如何使用 testng 对列表中的所有数据运行相同的测试用例? - How can I run the same test cases for all the data in a list using testng?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM