TestNG the official document of the Chinese translation of the 3rd chapter, see the original http://testng.org/doc/documentation-main.html
3-testng.xml
There are several different ways to invoke testng:
* Use Testng.xml file
* Use Ant
* from the command line
This section describes the format of the Testng.xml (the file will be followed by Ant and the command line).
The current Testng.xml DTD file can
Background: The use of testng in our project will be used to listen, mainly used to do some things before starting testng, and in the TestNG method after the run is done, we use listening, take the last caseThe Listener class inherits Testlisteneradapterand implements several methods
Package until;Import Org.testng.ITestContext;Import Or
My needs:1, Webdriver code on the SVN;2, Hudson (Jenkins) to perform the build, it downloads code from SVN, and uses Testng.xml to execute my set of test suites;3, connected, the result is placed in the specified position;My device:Development tools: IntelliJ IdeaAutomation Tools : Webdriver (selenium2.0)Continuous Integration tool: Hudson (its plug-in needs to be installed seleniumhq,testng,ant) These can be installed under the package or automatical
weather
Address of the interface: http://www.weather.com.cn/data/cityinfo/101010100.html
Request Method: GET
Request Result:
{
"Weatherinfo": {
"City": "Beijing",
"Cityid": "101010100",
"Temp1": "15 ℃",
"Temp2": "5 ℃",
"Weather": "Cloudy",
"IMG1": "D1.gif",
"Img2": "N1.gif",
"Ptime": "08:00"
}
}
2. Test target
Request the corresponding Cityid code, whether the returned city is the expected city.
3.1.2 New Java Project
St
TestNG, testing next Generation, the next generation of test technology, is a test framework built on JUnit and nunit ideas that uses annotations to enhance testing capabilities, which can be used for unit testing or integration testing. Installation: Help-->install New software Click Add to enter the dialog box that pops up: Click OK to install all the way TestNG combined with Selenium
New Java
TestNG is very powerful, @dataprovider can be used to do data-driven, data source files can be excel,xml,yaml, even can be txt text. In this case, take XML as an example:Note: The return value type of the @DataProvider can only be object[][] and iteratorTestdata.xml:XML version= "1.0" encoding= "UTF-8"?>Data>TestMethod1>Input>1Input>button>2button>TestMethod1>TestMethod1>Input>3Input>button>4button>TestMethod1>Testmethod2>Input>3Input>button>4button>T
Download Testng.eclipse PluginTestNG corresponds to the jar package, where the 5.12 version is usedDirectly find the MyEclipse installation directory, the Org.testng.eclipse_5.12.0.6.jar copy to D:\MyEclipse10\dropins, restart MyEclipse, There will be pop-up prompts to successfully install the Tesng plugin and version numberThen create your project and import the Testng-5.12.jar into your projectsOk!Copyright NOTICE: This article for Bo Master origina
TESTNG provides several interfaces for listeners and interceptors for our own development, by implementing these interfaces to define the behavior we want in testingInterface list:
Iannotationtransformer (Doc,javadoc)
IAnnotationTransformer2 (Doc,javadoc)
ihookable (Doc,javadoc)
Iinvokedmethodlistener (Doc, Javadoc)
Imethodinterceptor (Doc,javadoc)
ireporter (Doc,javadoc)
Isuitelistener (Doc, Javadoc)
Itestlistener
Testng is a very good test framework, really from the test point of view, for the test to think. In the testing process, we often encounter a scenario to do concurrent requests, mainly want to know if the program in the concurrency will be abnormal or not consider the other situation, this is often not to do performance testing, and not because of this and to use LR to do this thing. If you know more about testng
5.5-parameters
Test methods are not required to be parameter-free. You can use any number of parameters on each test method and instruct TestNG to pass the correct arguments.
There are two ways to set parameters: Using Testng.xml or programming.
5.5.1-parameters from Testng.xml
If you want to use simple values for your parameters, you can explicitly specify in your testng.xml:
@Parameters({ "first-name" }) @Test public void testSingleString(Strin
No Java test, no programming test, how far can you go??One months later, August unconsciously passed, work for 4 years, suddenly found themselves still so useless, outsiders seem to be bright, in fact, only their own know the panic. We all have the desire, all hope to live a good life, clothed, but you think you can do it? Sometimes I want to tell myself to make good efforts, good struggle, but also feel the future so confused. Nothing can catch, can't catch.I don't know where the future is. I d
xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > This dependency is provided by the JDK, container, or User. such as Servlet.jar. * runtime, used only at runtime, such as JDBC driver, for run and test Phases. *test, used only during testing, to compile and run the test Code. Will not be published with the Project. * system, similar to provided, needs to explicitly provide a jar containing dependencies, MavenIt is not found in Repository.
Sometimes, you may need to call the method in a particular order in a test case, or you want to share some of the state between the data and the method. TestNG supports this dependency test method by explicitly relying on it to support claims.TestNG allows you to specify dependencies, whether or not:Use the attribute Dependsonmethods in @Test comment orUse the attribute dependsongroups in the @test annotation.Use attribute Dependsonmethods for example
After logging on to Jenkins ', the main page has a Jenkins management option that goes into the module, configures the plugin and system.In the project advanced options, configure your project path;In version control options, if you do not have version control, select NoneBuild a BAT file that reads as follows and puts the bat in your local project's root directoryJAVA-CP E:\jenkins\workspace\WebUIAutomation\bin; e:\jenkins\workspace\webuiautomation\libs\* Org.testng.TestNG Sci_webui_bvt.xmlIn t
"Turn from" http://www.cnblogs.com/findyou/p/5388853.htmlDirectory3.1 HTTP interface (GET) test instance
3.1.1 To be tested Interface Description 3.1.2 New Java Project
1. Project Catalog description 2. Common.java Source code 3.getcityweathe.java source code 4.urlconnection.java
Source code 3.1.3 Write test Case
1. Test Case 2. Simplified use case
3.1.4 Execution of test cases
3.1.1 Description of the interface to be tested 1. National Weather Weather
Forecast In
1. What is Jenkins?is a continuous integration tool based on Java development for monitoring continuous duplication of work.2. Download and installHttp://www.cnblogs.com/zh-96/p/6445118.html3. New Task 4. Task ConfigurationAdding build steps Lnvoke AntContent:Save5. OperationProject left menu bar Click Build Now--drop-down menu--console output Run successfullyInterface Test (java+testng+ant+jenkins) fourth article Jenkins
1, Data code separation, convenient maintenance.The general practice is to save the data in Excel, which is read by the program.2. Read Excel data.The new Excel,a column in the D-Disk url,b the column-drop parameters. New Class Redexcel PackageCOM.LX;ImportJava.io.File;Importjava.io.IOException;ImportJxl.*; Importjxl.read.biff.BiffException; Public classredexcel{ Public Static voidMain (string[] args)throwsbiffexception, IOException {//reading data from coordinates B1 in a documentSystem.out.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.