Automated testing and continuous integration solutions


1. What is an interface test?

Interface testing is a test for testing the interfaces between system components. The interface test is mainly used to detect the interaction points between the external system and the system and between the various internal subsystems. The focus of the test is to check the data exchange, transfer and control management process, as well as the mutual logical dependence between the systems.

Interface testing is suitable for the underlying framework system and central service system that provide services for other systems. It mainly tests the interfaces provided by these systems to the outside and verifies its correctness and stability. Interface testing is also applicable to the service layer interface in an upper-level system. The higher the level, the more difficult it is to test.

Interface testing is implemented in a multi-system and multi-platform framework, and has an extremely efficient cost-benefit ratio. Interface testing inherently brings efficient defect monitoring and quality supervision capabilities to highly complex platforms. The more complex the platform and the larger the system, the more obvious the effect of interface testing.

Based on the importance of interface testing and its relatively easy to automate characteristics, continuous integration of interface monitoring can promptly discover problems in the project, which is very important for continuous operation of the project.

Second, the process of interface testing

1. After the project is launched, testers should find developers as soon as possible to get interface test documents

2. After obtaining the interface test document, you can write and debug the interface use case

3. After the interface use case is written and debugged, it is deployed to the continuous integration test environment.

4. Set basic parameters such as script running frequency, alarm mode, etc., and conduct daily monitoring of the interface

5. Daily maintenance and update of interface scripts and handling of interface exceptions

Three, write interface test scripts

Most performance tools can be used for interface testing. Jmeter is a useful performance testing tool. It can also be used for interface testing. Jmeter is more suitable for CGI, webservice, DB and other types of interface testing. The following takes the websevice api interface as an example to illustrate how to write interface test cases (this article focuses on the construction of the interface test platform, only a brief introduction to the specific tools is used, and if you don’t know the tools, you can Baidu by yourself):

The following is a simple script I made.

Each request adds a response assertion to determine whether it meets expectations.

If you use the command to execute, it is also very simple:

jmeter -n -t test.jmx -l test.jtl

Four, interface continuous integration

I have been here for a long time, mainly for report display. Before, I didn't want to use other tools (such as Ant, Maven), I just wanted to show the report of the jtl file, but I didn't succeed for a long time. Finally, I gave in to the tools and compiled with Ant.

Mainly configure build.xml

An example:

<?xml version="1.0" encoding="UTF-8"?>
<project name="ant-jmeter-test" default="all" basedir=".">
<tstamp>
<format property="time" pattern="yyyyMMddhhmm" />
</tstamp>
<!-- 需要改成自己本地的 Jmeter 目录-->
<property name="jmeter.home" value="F:\xxxxx\Jmeter" />
<!-- jmeter生成jtl格式的结果报告的路径-->
<property name="jmeter.result.jtl.dir" value="F:\xxxxx\resultLog\jtl" />
<!-- jmeter生成html格式的结果报告的路径-->
<property name="jmeter.result.html.dir" value="F:\xxxxx\resultLog\html" />
<!-- 生成的报告的前缀->
<property name="ReportName" value="TestReport" />
<property name="jmeter.result.jtlName" value="${jmeter.result.jtl.dir}/${ReportName}${time}.jtl" />
<property name="jmeter.result.htmlName" value="${jmeter.result.html.dir}/${ReportName}${time}.html" />

<target name="all">
<antcall target="test" />
<antcall target="report" />
</target>

<target name="test">
<taskdef name="jmeter" classname= "org.programmerplanet.ant.taskdefs. jmeter .JMeterTask" />
<jmeter jmeterhome="${jmeter.home}" resultlog="${jmeter.result.jtlName}">
<!-- 声明要运行的脚本。"*.jmx"指包含此目录下的所有jmeter脚本-->
<testplans dir="D:\test_case_path" includes="*.jmx" />
</jmeter>
</target>

<target name="report">
<xslt in="${jmeter.result.jtlName}"
out="${jmeter.result.htmlName}"
style="${jmeter.home}/extras/jmeter -results-detail-report_21.xsl" />

<!-- 因为上面生成报告的时候,不会将相关的图片也一起拷贝至目标目录,所以,需要手动拷贝 -->
<copy todir="${jmeter.result.html.dir}">
<fileset dir="${jmeter.home}/extras">
<include name="collapse.png" />
<include name="expand.png" />
</fileset>
</copy>
</target>
</project>

Install the "Publish performance test result report" and "Publish HTML reports" plug-ins on Jenkins, and configure it.

run.

The results are as follows:

If you add some concurrency, load, etc., it is a performance test report.

The curve display of the performance report hasn't come out yet, please check again when you have time.

Supplement the performance test report:

There has been an error before:

Performance: Recording JMeter reports ‘**/*.jtl’

Performance: no JMeter files matching ‘**/*.jtl’ have been found. Has the report generated?. Setting Build to FAILURE

Build step ‘Publish Performance test result report’ changed build result to FAILURE

Finished: FAILURE

Lead to the result not coming out. Later in Jmeter/bin will be in jmeter.properties:

jmeter.save.saveservice.output_format=csv

Change to:

jmeter.save.saveservice.output_format=xml

The result is this:


Finally: a wave of software testing data sharing!

In the technology industry, you must improve your technical skills and enrich your practical experience in automation projects. This will be very helpful for your career planning in the next few years and the depth of your test technology mastery.

In the interview season of the Golden 9th and the Silver 10th, the season of job-hopping, organizing interview questions has become my habit for many years! The following is my collection and sorting in recent years, the whole is organized around [software testing], the main content includes: python automation test exclusive video, Python automation details, a full set of interview questions and other knowledge content.

May you and I meet and you will find something! If you want to exchange experience in software testing, interface testing, automated testing, and interviews. Follow WeChat public account:[Sad Spicy Strips]Receive a 216-page software test engineer interview book for free. And the corresponding video learning tutorials are free to share! Communication learning skirt:313782132

Recommend good articles:

Packaged as a test engineer with 1 year of work experience, my advice before the interview is as follows

What exactly should I learn in automated testing?

Why not consider Tencent for job-hopping? Talk about a little bit of the past between me and the goose factory

Which is more advanced, automated testing or manual testing?

Novice must see: How to write a qualified test case?

Python login interface test problem record and solution (dry goods)

Guess you like

Origin blog.csdn.net/weixin_50829653/article/details/113994290