Java - Test - TestNG: testng.xml element class

1 Overview

  1. class-related elements
    1. classes
    2. class
    3. methods
    4. exclude
    5. include

2. Background

  1. ready
    1. Understanding of the package and its sub-elements
  2. problem
    1. I just want to test a few specific class
    2. I would like to do filtering methods of the class

3. Environment

  1. here
    1. idea
      1. 2018.2
  2. Profiles
    1. testng.xml
  3. Test Package Structure
    1. com.test01.Test1
      1. method101
      2. method102
    2. com.test02.Test2
      1. method201
      2. method202
    3. com.test03.Test3
      1. method301
      2. method302
  4. Promise
    1. Configuration file, I only interception suite following sections

4. Scene

1. Scene 1: perform certain class

  1. Outline
    1. Perform some test classes
      1. Of course, the use of this package can also be achieved with include
  2. Profiles

    <classes>
        <class name="com.test01.Test1"/>
        <class name="com.test02.Test2"/>
        <class name="com.test03.Test3"/>
    </classes>
  3. Explanation
    1. classes
      1. Outline
        1. The root element of class
      2. Nature
        1. Container element
          1. Nothing property itself
          2. As a parent element class elements
      3. note
        1. A test there can be only one
          1. More will complain
    2. class
      1. Outline
        1. Earth elements
      2. Nature
        1. Test class information
      3. Attributes
        1. name
          1. The class name
        2. other
          1. And there, behind say
  4. doubt
    1. Question 1: I would like to test a lot of class time
      1. plan 1
        1. Use package
      2. Scenario 2
        1. With one element of class
        2. class name attribute does not support regular
          1. and so...
          2. Feel a little unreasonable
          3. Well, we say that the next question

2. Scenario 2: I want to perform a certain test class method

  1. Outline
    1. Perform some test classes
    2. Specify the exact method
  2. Profiles

    <classes>
        <class name="com.test01.Test1">
            <methods>
                <include name="method.*"/>
                <exclude name="method.*2"/>
            </methods>
        </class>
    </classes>
  3. Explanation
    1. methods
      1. Outline
        1. The root element method
        2. But there is no way a child element
      2. Nature
        1. A container
    2. include & exclude
      1. Outline
        1. This was said in the package, not to say
        2. They certainly support regular

5. issue

1. Question 1: a class also appear in multiple class elements in

  1. Scenes
    1. The same class
    2. Appeared several times in class
  2. result
    1. Performed only once

2. Question 2: Methods include and exclude

  1. Scenes
    1. Same method
    2. The include and exclude multiple control
  2. result
    1. The same package
      1. The same operation is performed once at most
      2. include and exclude have the time, exclude high priority

3. Question 3: class conflict and package

  1. Scenes
    1. Class is a package exclude
    2. Classes are classes include
  2. result
    1. After the first class package
      1. Normal execution
    2. After the first classes packages
      1. It will be problems
        1. packages must be in front of classes
        2. These elements, a test can be only one
    3. If both include
      1. Normal execution
      2. Not repeat

6 Conclusion

  1. A suite where there can be multiple test
  2. A test, the only one groups, packages, classes
    1. And there was order
  3. groups, packages, classes 里
    1. include and exclude elements or good judgment
    2. But across the element, then
      1. exclude front element may fail
      2. include multiple elements does not result in the test multiple times

ps

  1. The number of contradictory elements across operational, feel the need to think about
    1. Cross-test have not considered it

Guess you like

Origin www.cnblogs.com/xy14/p/11837186.html