測試框架TestNg1 標籤,註解,套件測試

2021-09-24 22:12:41 字數 1206 閱讀 6381

引入:org.testng

testng

6.14.3

使用:@test

public void paysucess()

·  @beforesuite

- 對於套件測試,在此套件中的所有測試執行之前執行。

·  @aftersuite

- 對於套件測試,在此套件中的所有測試執行之後執行。

·  @beforetest

- 對於套件測試,在執行屬於標籤內的類的任何測試方法之前執行。

·  @aftertest

- 對於套件測試,在執行屬於標籤內的類的所有測試方法都已執行之後執行。

·  @beforegroups

:在呼叫屬於該組的第乙個測試方法之前執行。

·  @aftergroups

:在呼叫屬於組的最後乙個測試方法之後執行。

·  @beforeclass

- 在當前類的第乙個測試方法之前執行。

·  @afterclass

- 執行當前類中的所有測試方法之後都執行。

·  @beforemethod

- 在每個測試方法之前執行。

·  @aftermethod在testng中,我們無法在測試源**中定義乙個套件,但它可以由乙個xml檔案表示,因為套件是執行的功能。 它還允許靈活配置要執行的測試。 套件可以包含乙個或多個測試

是testng.xml的根標記。 它描述了乙個測試套件,它又由幾個部分組成。

下表列出了接受的所有定義的合法屬性。

簡單case如下:

<?

xml version

="1.0"

encoding

="utf-8"

?>

name="threadmulti" parallel="methods" thread-count="12"

>

name

="login"

>

name

="com.course.testng.suite.logintest"

>

name

="pay"

>

name

="com.course.testng.suite.suiteconfig"

>

name

="com.course.testng.suite.paytest"

>

測試框架之testng使用

註解 描述 test 標記乙個類或方法作為測試的一部分 beforesuite 註解的方法將只執行一次,執行所有測試前此套件中 aftersuite 註解的方法將只執行一次此套件中的所有測試都執行之後 beforeclass 註解的方法將只執行一次先行先試在當前類中的方法呼叫 afterclass ...

十 TestNG分組測試1

使用 groups 屬性 package com.lc.tesgfenzu import org.testng.annotations.aftergroups import org.testng.annotations.beforegroups import org.testng.annotatio...

python測試框架unittest(1)

需要測試的 如下 def add city country city,country city and country city country return city and country.title 先寫乙個簡單的測試類 import unittest from city country im...