Teach you how to build Interface Automation test framework with ECLIPSE+TESTNG

Source: Internet
Author: User
Tags testng


first, environmental installation


1. Prerequisites


Install the JDK to configure the Java environment variable installation eclips These are available on the web and are no longer detailed.


resource sharing link:http://pan.baidu.com/s/1v9Fw6



2. Install testng plug-in



Online installation due to the speed of the reason, slow. Here's how to install offline.



(1) Unzip the eclipse-testng offline package. zip



(2) Copy the folder org.testng.eclipse_6.8.6.20130607_0745 in "eclipse-testng offline package/feature" to the "MyEclipse installation directory/features" directory



(3) Copy the "Eclipse-testng offline package/org.testng.eclipse_6.8.6.20130607_0745" folder to the "MyEclipse installation directory/plugins" directory



(4) Restart Myeclipse,windows-show view-testng



3. Install Ant



(1) Extract apache-ant-1.9.6-bin.zip to any directory






(2) Configure the ant environment variable to be added at the end of the path variable: <ant directory >/bin;



Second. creating a Java project in eclipse



1. Java project, File---New, Eclipse, for example, fill in the window with project name and click Finish to complete the project creation.





2. Import the relevant JAR package: Project Right-click Build path, Configure build path ..., as shown in, open the Build Path configuration window. Import the testng plug-in that has already been installed, as shown in completing the import of testng: 3. Download the Lib.zip from the resource sharing link, unzip it, and import the jar package in the same way. The imported jar packages are used in the program.


Third. Writing test Cases using the TESTNG framework

1. Create the SRC folder, store the test-related code, and in the project right-click New folder, fill in the file name: src. 2. In accordance with the principles of data and code separation and public method extraction, my code structure is divided as follows: 3. Scripting Order 3.1 Global configuration file (Globalsettings.java) holds some project global variables, such as BaseURL, timeout, etc. 3.2 The HTTP protocol implementation (HTTPCLIENTHELPER.JAVA) implements the relevant request based on the protocol used by the project interface. Our project has two methods, one is to encapsulate the request parameters in the way of Namevaluepair, one is to encapsulate the request parameters in the way of Jsonobject, so the code is implemented for both methods. The 3.3 Interface Implementation (Glist_api.java) takes "create G-single" as an example to implement the interface: 3.4 Prepare the test data (Testdata.java) to prepare the test data for the interface. 3.5 test Data parameterization (Glistdataprovider.java), the number of parameters returned needs to be consistent with the number of function parameters in Testsuit. 3.6 test Case Suit (Glistcurd.java) 4. Test case debugging and execution according to step three to write all the use cases, can be used to debug and execute the use case. 4.1 Test Case Script debugging you can run the script by right-clicking on the test case suit Glistcurd.java on step three, "Debug as" or "Run as", "TestNG test". 4.2 Test Case Script execution There are two ways to run the script, testng or Ant. Run with testng, as in step 4.1. Using Ant to run, you need to create XML, refer to Build.xml, smoketest.xml in the repository. If you need to generate a testng report, you will also need to download the Test-result.xsi file. 4.3 Landscaping Results of the Operation report 


Teach you how to build Interface Automation test framework with ECLIPSE+TESTNG


Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.