兰帕德布劳内

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

selenium的suite配置

TestNg的xml基本格式:

<test name="Regression1">
  <groups>
    <run>
      <exclude name="brokenTests"  />
      <include name="checkinTests"  />
    </run>
  </groups>
  
  <classes>
    <class name="test.IndividualMethodsTest">
      <methods>
        <include name="testMethod" />
      </methods>
    </class>
  </classes>
</test>

suite:定义一个测试套件,可包含多个测试用例或测试group

suite 里可以设置是否使用多线程:

  

parallel="methods": TestNG will run all your test methods in separate threads. Dependent methods will also run in separate threads but they will respect the order that you specified.


parallel="tests": TestNG will run all the methods in the same <test> tag in the same thread, but each <test> tag will be in a separate thread. This allows you to group all your classes that are not thread safe in the same <test> and guarantee they will all run in the same thread while taking advantage of TestNG using as many threads as possible to run your tests.


parallel="classes": TestNG will run all the methods in the same class in the same thread, but each class will be run in a separate thread.


parallel="instances": TestNG will run all the methods in the same instance in the same thread, but two methods on two different instances will be running in different threads.

    • parallel="classes"  每个测试用例class级别多线程
    • thread-count="3" 线程数为5,可同时执行3个case
    • preserve-order="true"  根据官方解释(If you want the classes and methods listed in this file to be run in an unpredictible order, set the preserve-order attribute to false)设置为false乱序执行,设置为true会按照你配置执行
    • Parameter标签传递参数

给TestNg配置xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="classes" thread-count="5">
    <test verbose="2" preserve-order="true" name="TestDebug">  
        <parameter name="parameter1" value="parameter1" />
        <parameter name="parameter2" value="123" />
        <classes>
            <class name="com.dbyl.tests.passParameter" />
            <class name="com.dbyl.tests.TestngExample" />
        </classes>
    </test> <!-- Test -->
</suite> <!-- Suite -->

其中class是要执行的用例

posted on 2016-09-28 10:54  兰帕德布劳内  阅读(138)  评论(0)    收藏  举报