Java - Test - TestNG: testng.xml element package

1 Overview

  1. Introduction package elements
    1. packages
    2. package
    3. exclude
    4. include

2. Background

  1. ready
    1. Automatically generated file testng.xml
    2. We have a basic understanding of the structure of testng.xml
  2. problem
    1. How to test range bound
      1. Suppose I have a lot of test cases
        1. I want to perform all the time
        2. Or a part of the implementation

3. Environment

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

4. Scene

1. Scenario 1: I want to perform all the test classes

  1. Outline
    1. Perform all the test classes
  2. Profiles

     <suite name="All Test Suite">
         <test verbose="2" preserve-order="true" name="test 1">
             <packages>
                 <package name="com.test01" />
                 <package name="com.test02" />
                 <package name="com.test03" />
             </packages>
         </test>
     </suite>
  3. Explanation
    1. packages
      1. Outline
        1. The root element of the package
      2. Nature
        1. Is a container class elements
          1. Tell testng, this package are the following
          2. Feel such a design, it may be for efficiency
            1. package, class, different mechanism group performed
            2. Loss of performance toggling
            3. So try to focus together
    2. package
      1. Outline
        1. Package elements
      2. Nature
        1. Specifies the package to be executed
      3. Attributes
        1. name
          1. Name of the test class
      4. other
        1. use
          1. Need several packages, write directly on the line several packages

2. Scenario 2: package to perform a bit more, I can not be lazy

  1. Outline
    1. Perform all the test classes
    2. I want to be lazy
  2. Profiles

     <suite name="All Test Suite">
         <test verbose="2" preserve-order="true" name="test 1">
             <packages>
                 <package name="com.*" />
             </packages>
         </test>
     </suite>
  3. Explanation
    1. package
      1. Outline
        1. This uses regular
      2. with.*
        1. Regular
          1. With regular matches the package name
        2. note
          1. testng no wildcard
            1. No wildcard

3. Scenario 3: package to perform a little bit more, but I do not want to execute all packages

  1. Outline
    1. Most test execution
    2. But there is always such class, I do not want to perform
  2. Profiles

     <suite name="All Test Suite">
         <test verbose="2" preserve-order="true" name="test 1">
             <packages>
                 <package name="com.*" >
                     <exclude name="com.test03" />
                 </package>
             </packages>
         </test>
     </suite>
  3. Explanation
    1. exclude
      1. Outline
        1. Blacklist mechanism
          1. List in the package will not be executed

4. Scenario 4: package to perform a little bit more, but I do not want to execute all packages

  1. Outline
    1. Perform a small number of test
      1. And the last point it seems there are so different
  2. Profiles

     <suite name="All Test Suite">
         <test verbose="2" preserve-order="true" name="test 1">
             <packages>
                 <package name="com.*" >
                     <include name="com.test03" />
                 </package>
             </packages>
         </test>
     </suite>
  3. Explanation
    1. include
      1. Outline
        1. Whitelist mechanism
          1. Will perform whitelist package
        2. other
          1. In the same package, it is best not to mix and exclude

ps

  1. Documentation and Reference
    1. File
      1. Official Documents
        1. To be honest it is a page
        2. Pull the tail from scratch
          1. Things are talked about, but only when a dictionary to check
            1. You need some basic job
            2. But how to do basic
          2. Better things still did not speak
    2. books
      1. testng beginner's guide
        1. Good book
          1. 13-year basis
          2. no Chinese
    3. dtd
      1. testng.xml the dtd file
        1. Outline
          1. xml description file
          2. No problem correctness
            1. After all, this is in accordance with testng to resolve the
          3. Comment on relatively clear
            1. And reference may be complementary to the official website or
          4. Of course, it looks a bit of trouble
            1. Dtd required to know the syntax
        2. content
          1. element
            1. Meaning elements
            2. Properties of the elements
            3. Child of the element

Guess you like

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