简体   繁体   English

使用testng for webdriver一对一运行测试类

[英]Runing test classes one by one using testng for webdriver

I have written several test classes to test a web application using testng. 我编写了一些测试类来使用testng测试Web应用程序。 Each and every test classes are independent.(I use Java,maven and selenium webdriver) 每个测试类都是独立的。(我使用Java,Maven和Selenium Webdriver)

I have defined my test classes and test groups in the testng.xml as below. 我已经在testng.xml中定义了我的测试类和测试组,如下所示。

<test name="generalTest">
        <groups>
            <run>
                <include name="login"  />
                <include name="signUp"  />
                <include name="profileCreation"  />

            </run>
        </groups>

        <classes>
            <class name="my.test.Test_1_LoginTestCases"/>
            <class name="my.test.Test_2_SignUpTestCases"/>
            <class name="my.test.Test_3_CreatePeopleProfileTestCases"/>

        </classes>
    </test>

and I run this command in the command line to run test classes. 我在命令行中运行此命令以运行测试类。

mvn test -DsuiteXmlFile=/src/testng.xml -Dgroups=login,signUp,profileCreation

And I have used testng "priority" tag to define the order to run test cases inside test classes. 而且我使用了testng“ priority”标签来定义在测试类中运行测试用例的顺序。

But the problem is when i run testng.xml using above command, it runs all test classes same time(parallely).If there are 10 test classes then it opens 10 web browser instances same time and try to run every test classes same time. 但是问题是当我使用上述命令运行testng.xml时,它将同时运行所有测试类(并行)。如果有10个测试类,则它将同时打开10个Web浏览器实例并尝试同时运行每个测试类。

What I need is to run first test class and when it is completed then start running the second test class using the above maven command. 我需要运行第一个测试类,并在完成后再使用上述maven命令开始运行第二个测试类。

can any one help me to do this? 谁能帮我做到这一点? I really appreciate the help. 我非常感谢您的帮助。

只需在xml中像这样添加属性parallel =“ false”:

<test name="generalTest" parallel="false">

I solved the issue! 我解决了这个问题! :) I have put same priority range on all test classes. :)我在所有测试类上都设置了相同的优先级范围。 Ex: in every test classes i have set priority 1. Then it tries to to run that priority 1 test cases at same time. 例如:在每个测试类中,我都设置了优先级1。然后它尝试同时运行该优先级为1的测试用例。

Fix: 固定:

Use different priority range inside every test classes according the order that we need to run test suite as a whole. 根据我们整体运行测试套件所需的顺序,在每个测试类中使用不同的优先级范围。 Ex : Since I need to run first test class and after complete it then second test class to run, I set priority range 1 to 50 for first test class and 例:由于我需要先运行第一个测试类,然后再运行第二个测试类,所以我将第一个测试类的优先级范围设置为1到50

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM