Home > Mobile >  The interface test cases
The interface test cases

Time:10-07

Interface basic introduction
Why learn interface test: more will be used in the development of the current application development to an interface,
Why in the application development using the interface
With the definition of interface is equivalent to a set of standards, can regulate our development process,
Interface can ensure data security,
Interface can make our project more easy migration,
What is the interface
We can understand the interface for is the smooth interaction between different operating standard
The interface test
Definition: in the test program we can understand the interface test is to test whether a certain standard to work a kind of test,
Interface testing principle: [interface test is based on some kind of agreement] to simulate the client sends a request to the server,
The interface test test point
Request: testing request address is correct, whether or not the request by properly,
Test data: whether interface returned data and expected
Test security: some interface is not exposed, we need to verify first to test,
Test performance: for example, an interface point at the same time to have a lot of users to visit at the same time,
Interface test categorization
Web interface: the server interface + third-party interface
Module interface: the so-called module we can be understood as a different function within the client software, so the module interface is the software interaction between different functions within a standard,
Test the plug-in introduces basic
Postman it is a special plug-in chrome
Restclient it is developed by Chinese apply to the firefox browser plug-in
Jmeter is an independent testing tool
Test the plug-in installation and use the
Test the functionality of the plug-in is to complete a simple interface to help us on the browser test the main type of work,
Restclient plug-in:
Open firefox browser - add-in panel -- -- -- -- -- - search for specific plug-in name -- -- -- -- -- - download and install successful online
Browser in the upper right corner will be a specific icon, click on the icon to launch the plug-in, then we can do simple test operation,
Postman plug-in:
The plug-in because no direct online installation, so we need to prepare plug-in first unzip the package
Open chrome - add-in - mode enable developers - add has extracted package - enabled installed plugin [in chrome find application in a new TAB click on start the postman]
Restful style
Definition: we can understand a restful as a variety of interface design standards, it is not a specific interface
Restful specific performance:
http://server address: [port]/[project name]/[version number]/[resource collection/* * * *]/[a single resource]
Note:
01: [] in the content of the said can omit
02 HTTP: this is our most current applications of a network transmission protocol,
03 server address: storing the exact location of the network of our project, the specific IP address []
04 port number: specific resource location number
05 resources: we want to is it can be understood as the current interface from the server to the content of the
Common HTTP request and return a status code
HTTP common operation method:
The Get: from the server resources,
Post: the new resource to the server
Put: update the server resources
Delete: Delete the server resources
Return a status code:
200 get success
200/201 of the corresponding operation is put post get
204 the delete delete,
Based on the student information system project operation
Installation project:
Cmd cut the project's current location, and then according to the prompt for our online installation depend on package command execution,
After the success of the installation, we can through the python run_server. Py to start our service operation, by default it is occupied by the port 8000 [at the moment we can directly from the original API interface address on the document copy]
Restclient plug-in testing program to add delete to check
Select normal operation method, fill in the specific interface address and the corresponding packet, [current only need demo and see]
Test tool basic introduction
Why use the test tool
We want the user to request a particular interface 100 consecutive,
We now require 100 users to request an interface at the same time,
In the actual test will often meet continuous test operations (login - post - discovered)
Above all we can find that in many of the actual test operation is our through manual or simple plugin is that there is no way is very good, so we can consider to use functional test tools,
Jmeter basic definition: it is a by the apache development and maintenance of an open source software, [composed of Java write]
Jmeter can do
The interface test
Performance test
Java test
Database testing
The advantages and disadvantages of Jmeter
Because it is open source software so the biggest advantage is likely to be free,
Also because of the open source so we can be directly downloaded to the corresponding source code on the net, if later we find ourselves in the process of using special needs a certain function and jmeter itself and no, at this point we can expands itself [using Java]
Compared to other commercial test software, on the premise of realize the same function it takes volume smaller,
Disadvantages
Jmeter is no way to realize IP spoofing,
There is no interface jMeter test, we are all done through the interface test data as a result,
Jmeter running environment configuration
Because jmeter is composed of Java to write a software so run it on the machine must be equipped with the appropriate execution environment,
Related terms and concepts introduced (understand)
Jdk: it is a Java development kit, commonly used in the development of application specific (programmers), containing within it the jre and JVM
Jre: relative to the Jdk is a corresponding Java software running environment, it contains the JVM,
The Jvm: it is a Java virtual machine, its main function is to help us achieve cross-platform Java software,
Conclusion:
01 JDK and jre by comparison it is usually used in the production environment and the jre is used to run has good software production,
02 if we want to run on a machine corresponding Jmeter software can be installed directly corresponding to the JDK environment,
The specific environment Settings
We go to download the corresponding Jdk installation package, [version suggested above 1.7]
When we have the specific installation package only need to perform the corresponding operation installation, this process of we need to remember its installation directory,
When we can go to after the success of the installation configuration corresponding system environment variables,
The above after the operation is completed, we can through certain command line statements to verify whether the installation and configuration is successful,

Thread group basic introduction
Definition: we can understand the thread group as we need to send the request of actual users,
Native of classification: the default thread group in Jmeter is studied.the thread group:
Setup the thread group: what needs to be done before a request specific execution,
Teraddown thread group in a request specific what needs to be completed at the end of line, please,
Thread group: it is a regular user, use frequency is highest,
Thread group related attributes:
After sampling device error action of execution
Continue to ignore the current error and then continue to run directly,
Start next thread loop: ignore the error and then following the Start over continue
Wrong stop threads: the current thread off, and then other threads continue,
Stop testing: in the current error after the following the process execution will stop the test plan,
Stop the test now, immediately Stop all test operations
C) the number of threads: set a specific said that the current value is prepared for many users,
D) prepare time: unit is s said that the current all the threads will be done in such as how many seconds for
F) the number of cycle: set a specific numerical said the current request will be executed many times
G) scheduler: you can set the specific time for the test plan is a controlled time management operation,
Test pieces
Test clips belong to the same level, and thread group
Test pieces which contain the content of the default is not executed, is generally when needed by other components make it able to perform,
Jmeter components introduces basic
Element classification [it can be understood as the data type of programming language]
Components: we can achieve a collection of components that some of the same effect in Jmeter called element,
01 logic controller: we can be divided into two categories, one is used to classify the current operation, another category can be used to perform accordingly to the operation of the specific control,
02 configuration element: the element is typically used to provide data support for the specific operation,
03 timer: it can help us to control the operation time,
04 pre processor: one to apply for a real may need to complete the operation of the other, before we can be done by this element,
05 sampler: it is true of jmeter to perform the requested element,
06 post processor: when a request is completed after if you want to do some corresponding operation can be based on this element,
07 asserts that we can based on the expected result for the realization of the current request to return the result to the corresponding judgement,
08 listener: it is our test provides visual graphic display interface,
Jmeter components scope
Scope: we are in the middle of the jmeter scope can be understood as the scope of work is component,
There exist eight components in jmeter, we they can be divided into three categories:
Logic controller: it to the "child" below it has absolute controller,
Sampler: because the components are ultimately need to be performed, so where is it in yuan so-called, do not affect function
The other six: about the six components we prepared for them in a word, if a component's father is a sampler, then the components of the current sampler to work, if the component's father is not then the components of the current sampler under the father of all child elements play a role (can penetrate)
Jmeter components execution order
By default if the eight components are then their execution order is: logical controller - configuration element - the front processor - sampler - post processor assertions -- -- -- -- -- - -- -- -- -- listener

Jmeter recording script
Script: for jmeter suffixes can be called the JMX file called script,
Record: the so-called recording can be understood as the original manually add some operations through the other form is saved as a process of Jmx,
Jmeter how to realize the recording:
In Jmeter workbench to add an HTTP proxy server, and then set its attributes of "target controller" right [a thread group is added in the test plan, then check this], after will need to start will only take effect, the current service
Suggest you choose Internet explorer (because using the proxy pattern will be on the Internet think there are some security issues), in the Internet options at this point we need to configure the corresponding proxy server configuration [127.0.0.1-8080]
After the above operation is completed in the browser to manual operation, and then these operations will be preserved in Jmeter, convenient we follow-up tests,
  • Related