<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] Test.xml文件可以更方便的管理和執行測試用例 ## **一、Test.xml-suite:** suite為Test.xml的根節點 @name: suite的名稱,必須參數,會體現在測試報告中。 @parallel:是否多線程并發運行測試 @configfailurepolicy:一旦Before/After Class/Methods這些方法失敗后,是繼續執行測試還是跳過測試;可選值 (skip | continue),默認"skip" @skipfailedinvocationcounts:是否跳過失敗的調用,可選值(true | false),默認"false" @object-factory:一個實現IObjectFactory接口的類,用來實例測試對象 @preserve-order:順序執行開關,可選值(true | false) "true" @group-by-instances:是否按實例分組,可選值(true | false) "false" <br> <br> ## **二、Test.xml-test:** @name:test的名字,必選參數,會體現在測試報告中。 @parallel:是否多線程并發運行測試 @enabled:設置當前test是否生效,可選值(true | false),默認"true" @skipfailedinvocationcounts:是否跳過失敗的調用,可選值(true | false),默認"false" @preserve-order:順序執行開關,可選值(true | false) "true" @group-by-instances:是否按實例分組,可選值(true | false) "false" <br> <br> ## **三、全局參數Parameter** 此屬性在xml文件不是非必要的屬性,如果測試用例中有使用@Parameter定義的參數,則需要填寫此屬性。 **xml文件** ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="All Test Suite"> <!--測試套件--> <test verbose="2" preserve-order="true" name="/Users/XXXX/IdeaProjects/IdeAjava_test"><!--測試集--> <classes><!--測試類集合--> <class name = "Testng.day01testngTest"/><!--對應的每一個測試類--> <class name = "Testng.demo"/> </classes> </test> </suite> ``` **測試用例:** ``` public class day01testngTest { @Test public void testTestEmailGenerator() { demo str = new demo(); int res = str.add(10,20); int cc = 30; Assert.assertEquals(cc,res); } @Test public static void BeforeTe(){ System.out.println("我是【BeforeTest】注釋的方法將在屬于<test>標簽內的類的所有測試方法運行之前運行。"); } ``` <br> <br> **四、調用測試方法** 調用測試用例,執行`Testng.day01testngTest`中所有方法 **調用測試類中的具體方法:執行**Testng.day01testngTest類中方法名為**BeforeTe的測試方法** ~~~ <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="All Test Suite"> <!--測試套件--> <test verbose="2" preserve-order="true" name="/Users/XXX/IdeaProjects/IdeAjava_test"><!--測試集--> <classes><!--測試類集合--> <!-- <class name = "Testng.day01testngTest"/>&lt;!&ndash;對應的每一個測試類&ndash;&gt;--> <class name = "Testng.day01testngTest"> <methods> <include name="BeforeTe"></include> </methods> </class> </classes> </test> </suite> ~~~ **關鍵部位** ``` <class name = "Testng.day01testngTest"> <methods> <include name="BeforeTe"></include> 具體的方法名 </methods> ``` **運行結果:** 我是【BeforeTest】注釋的方法將在屬于<test>標簽內的類的所有測試方法運行之前運行。 =============================================== All Test Suite Total tests run: 1, Passes: 1, Failures: 0, Skips: 0 =============================================== Process finished with exit code 0 <br> <br> ## 五、testng.xml ?配置詳解 testng.xml的基本格式可以在[官網](https://testng.org/doc/index.html)上查看,基本格式如下: ``` <project default="test"> <path id="cp"> <pathelement location="lib/testng-testng-5.13.1.jar"/> <pathelement location="build"/> </path> <taskdef name="testng" classpathref="cp" classname="org.testng.TestNGAntTask" /> <target name="test"> <testng classpathref="cp" groups="fast"> <classfileset dir="build" includes="example1/*.class"/> </testng> </target> </project> ``` **結構如下:** \-結-構-樹 **suite** **\--tests** **\----parameters** **\----groups** **\------definitions \------runs** **\----classes** **\--parameters** <br> <br> **詳細的結構如下:** ``` <test name="xxxx">   <!-- 參數定義的方法 -->   <parameter name="first-name" value="Cedric"/>   <!-- groups的用法,前提是需要存在classes的組,否則所有方法不被運行 -->   <groups>   <!-- 定義組中組的方法 -->     <define name="groups_name">       <include name="group1"/>       <include name="group2"/>     </define>     <run>       <!-- 此處用組名來區別 -->       <inclue name="groups_name" />       <exclue name="groups_name" />       </run>   </groups>   <!-- classes的用法,classes中包含類名,類名底下可以包含方法名或排除方法名 -->   <classes>     <class name="class1">       <methods>         <!-- 此處用方法名來區別 -->         <inclue name="method_name" />         <exclue name="method_name" />       </methods>     </class>   </classes> </test> ``` <br> <br> **元素說明:** **![](https://img.kancloud.cn/64/40/64406042e4a8a493affb3de9d5c347ff_53x19.png)testng.xml文檔中最上層的元素** 說明:一個xml文件只能有一個![](https://img.kancloud.cn/41/09/41092c60476dac0753490d42a9f9af1c_87x28.png),是一個xml文件的根級![](https://img.kancloud.cn/b9/b7/b9b7a798dadef8ac5018316968a9e95d_71x25.png)由![](https://img.kancloud.cn/e5/36/e536a67185f0c1722afbe2ae5a769265_66x31.png)和![](https://img.kancloud.cn/be/2f/be2f812f8f16ee38c9e0d1097154fbfd_135x28.png)組成 參數說明: **suite屬性說明:** @name: suite的名稱,必須參數 ? ? @junit:是否以Junit模式運行,可選值(true | false),默認"false" @verbose:命令行信息打印等級,不會影響測試報告輸出內容;可選值(1|2|3|4|5)? @parallel:是否多線程并發運行測試;可選值(false | methods | tests | classes | instances),默認 "false" @thread-count:當為并發執行時的線程池數量,默認為"5" @configfailurepolicy:一旦Before/After Class/Methods這些方法失敗后,是繼續執行測試還是跳過測試;可選值 (skip | continue),默認"skip" @annotations:獲取注解的位置,如果為"javadoc", 則使用javadoc注解,否則使用jdk注解 @time-out:為具體執行單元設定一個超時時間,具體參照parallel的執行單元設置;單位為毫秒 @skipfailedinvocationcounts:是否跳過失敗的調用,可選值(true | false),默認"false" @data-provider-thread-count:并發執行時data-provider的線程池數量,默認為"10" @object-factory:一個實現IObjectFactory接口的類,用來實例測試對象 @allow-return-values:是否允許返回函數值,可選值(true | false),默認"false" @preserve-order:順序執行開關,可選值(true | false) "true" @group-by-instances:是否按實例分組,可選值(true | false) "false" **test屬性說明:** @name:test的名字,必選參數;測試報告中會有體現 @junit:是否以Junit模式運行,可選值(true | false),默認"false" @verbose:命令行信息打印等級,不會影響測試報告輸出內容;可選值(1|2|3|4|5)? @parallel:是否多線程并發運行測試;可選值(false | methods | tests | classes | instances),默認 "false" @thread-count:當為并發執行時的線程池數量,默認為"5" @annotations:獲取注解的位置,如果為"javadoc", 則使用javadoc注解,否則使用jdk5注解 @time-out:為具體執行單元設定一個超時時間,具體參照parallel的執行單元設置;單位為毫秒 @enabled:設置當前test是否生效,可選值(true | false),默認"true"? @skipfailedinvocationcounts:是否跳過失敗的調用,可選值(true | false),默認"false" @preserve-order:順序執行開關,可選值(true | false) "true" @group-by-instances:是否按實例分組,可選值(true | false) "false" @allow-return-values:是否允許返回函數值,可選值(true | false),默認"false"
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看