Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

TestNG (1)-- start

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

You can get information from http://testng.org/doc/documentation-main.html.

I. brief introduction

TestNG is the acronym of test next generation, that is, the next generation of testing technology, if you have come into contact with junit or nunit, it may be easier to understand, but I believe there are many people like me, have not touched, pure rookie, in that case, step by step, start with the most basic.

TestNG is an annotation-based testing framework that can be used for both unit testing and integration testing.

A complete test consists of three steps:

Write test business logic and insert TestNG annotations into the code

Add your own test information to testng.xml or build.xml

Run TestNG.

Note: list of annotation programs supported by TestGN:

-- @ BeforeSuite,@BeforeTest,@BeforeClass,@BeforeMethod,@BeforeGroups

-- @ AfterSuite,@AfterTest,@AfterClass,@AfterClass,@AfterGroups

-- @ DataProvider

-- @ ExpectedExceptions

-- @ Factory

-- @ Test

-- @ Parameters

II. TestNG.xml Foundation

TestNG.xml is a configuration file from which the testNG runtime gets information, such as which method in which class to run, and so on. If you don't have a writing prompt when writing testNG.xml, you can add it to the head:

First understand some basic concepts, do not understand it, first look at:

A suite (suite) is a xml file (although the title is testNG.xml, do not be limited by it, the name can be arbitrarily chosen), it can be composed of one or more tests, marked as

A test (test) consists of one or more classes marked as

A class (class) consists of one or more methods marked as

Method (method) is a java method marked by @ Test in your code.

As mentioned earlier, we can specify the configuration of the test we run this time in the xml file. For example, we can specify the package name, class name, method name, and so on. Look at a xml file first and have an impression:

As you can see, this suite contains two test, and the second test has two class.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report