- Why do automated testing
- What projects suitable for automated testing
- Select Interface or UI Automation Automation
- Interface Automation Tools Comparison
- Jmeter + Ant + jekins frame structures
First, why do automated testing?
Assuming that half the iteration time, each iteration requires five test, artificial regression need five hours once finalized one year, eliminating 600 hours automated for you, which is 75 days, while also eliminating the old test an error occurred at a function to spit tired trouble and people.
A little: to improve the efficiency, quality
Automated testing: Artificial driven test machine to perform the process of converting the behavior (in a manual basis)
Second, what projects suitable for automated testing?
1. What is the project for?
Demand is stable, does not change frequently (project stability)
Development and testing cycle is long, need to perform frequent regression testing
Run the same test scenario to be repeated on multiple platforms (Compatibility Test)
Some test items can not be achieved through manual testing, manual or too costly
Tested more standard software development, the system can ensure testability
2. What stage of writing automated scripts?
After the project is stable, more handy to write automation use cases, reasons:
Project basically no bug, easy to write assertions (assertions similar to manual testing in the expected results)
When writing complete manual test cases have been automated test scripts can to achieve according to the manual test
3. What stage of automated testing?
Project testing process: smoke tests - new needs test - Compatibility Testing - Regression Testing
Smoke testing: testing process important starting point
New needs test: the testing process of learning, exploring the most concentrated test
Compatibility Test
Regression testing: test the impact of stabilization function whether it has received new features
Regression testing and compatibility testing for automated testing, the former need to perform a large number of regression test cases, the latter need to repeat
Third, choose what type of automated testing
Automated Test Category:
UI Automation (low efficiency, high cost, the user operates the authenticity of the strong)
Interface Automation (user operation authenticity is not strong)
unit test
Performance Testing
Automation UI Automation interfaces and may produce complementary test (method)
Fourth, the interface comparison tool
Interface tool should meet the needs of:
Easy to write interfaces
Convenient debugging interface
Support data initialization
Generate test reports
Supports parameterized
Interface testing tools comparison:
Fiddler: Ethereal artifact, http protocol debugging proxy tool that can record http protocol for communication between the Internet, you can set breakpoints, view all "out of" Fiddler data (such as cookie, html, js, css files, etc.)
Interface testing can be carried out, can not say
Postman:
Possible to send any type of HTTP request (GET, HEAD, POST, PUT ..), can upload files responsive to the authentication, variable management, environmental parameter management may be batch management and operation of further use cases and supports the export use cases, introduction may be automated testing interface
The disadvantage is that automation is not strong enough to assert, can not jenkins, code management repository continuous integration testing
soapUi:
Open source testing tool to check through soap / http, calls implement the interface and performance testing of Web Service. The tool can be used as a separate software testing, using a plug can be integrated into Eclipse, maven2.X, Netbeans intellij and use.
Jmeter:
Is a 100% pure Java free open source tools, mainly used for performance testing, but also can do interface testing, with the post processor and assert that meet most of the interface test scenarios, JMeter provide programming capability BeanShell , you can write more flexible test script, by jmeter + ant + jenkins can implement interfaces and performance automated test.
Code
java code implements an interface test: java package can httpclient.jar using such elements JUnit or TestNG testing tool written embodiment, the interface implemented in conjunction with jenkins continuous integration testing.
python code implements an interface test: python may be utilized to achieve a powerful interface to third-party libraries Requests use cases written unittest binding unit testing framework, generate test reports, and may continue to do jenkins integration testing.
Why should test the code to implement the interface?
Limited tools, many tools are difficult to simulate test scenarios, scenes and complex data structure, code can implement an interface, the statistics show flexibility. Write your own test framework and code.
Small and medium sized projects recommended postman and jmeter, for large projects or the use of code.
Five, jmeter + Ant + Jenkins frame structures
General idea: Jmeter can do interface testing, stress testing can do, and is open source software; Ant is a Java-based build tool, complete script execution and results of mobile phones generate reports across platforms; Jekins continuous integration tool. These three combine to build a WebHTTP interface test of continuous build environment, implement the interface automated testing, based on win
- Installation jmeter
1.1 Download the installation package
Jmeter rely java runtime environment, advance to download and configure the environment variables jdk
Download the official website: http://jmeter.apache.org/download_jmeter.cgi
Once downloaded directly extract
1.2 Configuration Environment Variables
JMETER_HOME installation path is jmeter
CLASSPATH为%JMETER_HOME%\lib;
PATH is% JMETER_HOME% \ bin;
1.3 Installation Verification
Enter jmeter -v command window, then the version to appear jmeter success
You can enter a carriage return after jmeter directly in the command window to start jmeter; you can start clicking jmeter jmeter.bat file
1.4 through a debug interface on jmeter (if multiple interfaces are added according to the method jmeter)
- Ant installation
2.1 installation package download
Official website to download ( http://ant.apache.org/bindownload.cgi ), I used version 1.10.1, downloaded directly extract
2.2 Configuration Environment Variables
ANT_HOME for the ant-extracting position
CLASSPATH is% ANT_HOME% \ lib;
PATH is% ANT_HOME% \ bin;
2.3 Installation Qualification
Verify the installation, the command line ant -v, the version information appears the installation was successful
- Ant configuration Jmeter: to mobilize the ant build command execution jmeter interface testing and generate test reports
3.1 configuration file library
Copy the ant-jmeter-1.1.1.jar files under jmeter extras directory to the lib file in the ant installation directory folder to find the "org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" This class this ant is running, to successfully trigger JMeter scripts
3.2 Configuring the ant build file build.xml
Create a script and stored in the report jmeter root folder testcases
New build.xml file testcases folder, modify the contents of the document
Note: jmeter the extras file also has a build.xml file, do not use this document to change, are two different things, build their new document is here
Tab key code can not exist otherwise it will fail to compile the script to be executed should be specified, otherwise there will be problems
Modify the following documents according to the actual situation:
https://www.cnblogs.com/autobyme/p/8387407.html--- the blog which can be replicated in the configuration build.xml
3.3 jmeter.propertise document
Jmeter.properties find documents in jmeter / bin directory, open the document to edit, modify jmeter report output format is xml
Jmeter.save.saveservice.output_format = csv to change jmeter.save.saveservice.output_format = xml, and removed from the front symbol # Notes
3.4 verify the configuration, perform a test build
Before jmeter script to save and build.xml configuration file in the same directory test scripts directory as follows:
3.5 Test execution
Open a command window, type ant run, a test is performed in the same directory as build.xml
3.6 View test report
Html and see if there jtl results are reported in the report output storage path, the path is stored in the document also build
Open html documents, test results show the name of the execution of the use case, the success rate, the use case execution time and other parameters results
Such a result is not intuitive
3.7 Optimization Test Report
(1) optimize the download template jmeter-results-shanhe-me.xsl, copied to the extras directory of jmeter
Content (2) arranged to output a test output report: jmeter.properties likewise, the need of setting the output is true, and remove the front comment symbol #, where all set to save true-
Report templates (3) set the build file as a template jmeter-results-shanhe-me.xsl optimized
(4) again with ant build test, the test report after viewing optimization
- Installation jenkins (two ways)
4.1 Download the installation package to extract
1. Download the msi file (double-click to install)
2. to deploy jekins with servlet container, the tomcat
https://www.cnblogs.com/dreamyu/p/6480980.html
4.2 start jenkins
After installing the browser input http: localhost: 8080
From the installation directory jenkins \ sercrets find initalAdminPassword file, enter a password
Mounting Options widget and choose to install the recommended way
Create the first administrator account
Or skip this step, and using the default admin administrator login
4.3 Configuration jenkins
1. It should be configured invoke ant plugin, HTML test report truly plug-ins
(1) create an administrative install HTML Publisher Plugin and Ant in Workspace in jenkins (if at the beginning of the default recommended to install the plug-in installed ant, ant here do not have to download plug-ins)
(2) In jenkins System Management - the system setup, configuration and Ant jdk
2. Create and configure a project
Note: ant build the project, the default script is executed under Jenkins in the workspace, if there is no script in the workspace will build error, and the script build.xml files are placed under the workspace directory (I put down jmeter)
Note: Index page [s]: value (TestReport.html) test report is consistent with the build.xml name set in, or can not view the test reports in Jenkins
The configuration script finishes
4.5 project home page, click on the building immediately, perform the test
References:
https://www.cnblogs.com/autobyme/p/8387407.html
https://www.cnblogs.com/wulixia/p/11011793.html
https://blog.csdn.net/XingLongSKY/article/details/91536924