JMeter Single Interface test scheme (interface without business association)

Source: Internet
Author: User
Tags vars

Objective

In front of an article about the use of jenkins+jmeter+ant, but did not say how to invest in the use of the project, the main introduction of the interface test definition, process and environment deployment, so what I would like to talk about today is how I put this project into practical use. This scenario is primarily used for tests that have no business correlation between interfaces.

Process of structural design and data preparation interface testing

1. After the project starts, the tester should find the developer to get the interface test document as soon as possible.
2. After obtaining the interface test document, the interface use case can be written and debugged.
3, the interface use case writing debugging is completed, deployed to the continuous integration of the test environment,
4, set the script running frequency, alarm mode and other basic parameters, the daily monitoring of the interface
5, daily interface script maintenance updates, interface exception processing

Jmeter+jmeter+ant overall structure design of jmeter test process

Test data

My test data is managed in CSV, including the domain name, url, method (get or post), parameters, expected results (can be multiple), using Excel to create and then convert to CSV format, so we just need to maintain our use case in Excel.

From the data format can be seen, do the use case of the execution of the logo, select Yes when the execution, no when not executed, this is a use case selection of the execution of a simple design, and the method of the request is also selectable, the current project is mainly used post and get, in addition to get the use case name, Called interfaces and specific test request data, which is the module that uses Excel to manage test cases

Note: JMeter values that contain Chinese characters may error, modify ${jmeterhome}/bin/jmeter.profile

# The encoding to being used if none is provided (default iso-8859-1) #sampleresult. default.encoding=iso-8859-1sampleresult.d Efault.encoding=utf-8

The configuration is basically complete, followed by the project's directory schema:

    1. The./test_play/directory is used to put the case file generated by JMeter (note when writing, do not use absolute paths, or the subsequent maintenance costs will increase)
    2. The./test_suit/directory is used to put the relevant configuration files required for JMeter testing
    3. ./resource/directory to hold some document information related to the project
    4. Build.xml file, ant configuration file
    5. If you read the Build.xml file, you will get an auto-generated directory./report, there are two directories JTL and HTML, which are used to place test reports in different formats.
Script Design

Add a CSV Data Set Config to fill in our text path

Add BeanShell preprocessor and BeanShell postprocessor, the main purpose is to deal with Chinese garbled

Add if controller, according to Case_satus to determine whether the use case is executed, according to Ament is the HTTP request or Java request, according to method, to determine the execution of a GET or POST request

Set an assertion to determine if our results are correct

Set the number of cycles based on use cases

    • You can use the Java direct value to determine how many use cases are executed
    • String filename=vars.get ("Jf_api_data"); String [] datalist=new string[20]; String Content;inputstream openfile = new FileInputStream (filename); Workbook wb = Workbook.getworkbook (OpenFile); Sheet firstsheet = wb.getsheet (0); int totalrows=firstsheet.getrows (); int rows=totalrows-1;    Minus 1 is because I do not take the title line, in order to start from the second row to fetch string data=rows.tostring (); Vars.put ("Row", data)   ; Use routine number wb.close ();

       

Run debugging, view results

Access Jenkins

After the script design, the access to Jenkins with ant to implement JMX can be, as to how to use can read my previous article, Report preview:

JMeter Single Interface test scenario (interface without business association)

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.