Analysis and Design of Automated Testing

I. Introduction

        I recently read a good paper "Design and Implementation of Smart Home Mini Program Automated Testing" [1] and benefited a lot. The author's concise and beautiful language gave me a clearer understanding of software automation testing.

2. Project analysis

        Based on the smart home applet, the author summarizes the reasons for promoting automated testing, and conducts a feasibility analysis and page analysis of the project.

1. Reasons for automated testing

(1) Complex page elements: The page of the applet is composed of View (view), Layout (layout), Menus (menu), Widgets (interface) and other parts, and the page elements are many and complex. If manual testing is used, it takes a lot of time to complete element testing; if automated testing is used, a lot of manpower and material resources can be saved. When writing scripts, you can use methods such as XPath to locate elements.

(2) The testing process is complicated: the testing work is usually carried out after the development of the front-end and back-end, and the intervention is late, and the testing time is not sufficient, so it is difficult to guarantee the software quality. Therefore, a test barrier is added between front-end and back-end development, that is, interface testing. After the back-end interface is delivered, the interface automation test is carried out. If there is a problem with the interface, the back-end problem can be found in advance without calling the front-end, which saves time.

2. Feasibility Analysis

(1) Economic feasibility: that is, the cost issue, the tools and technologies used in automated testing are all open source and free.

(2) Technical feasibility: JMeter+Ant+Jenkins framework is used for interface automation test design, and Appium is used for page automation test design. The technology is open source and easy to learn.

(3) Operation feasibility: the framework is simple and easy to operate, and the page is also simple and easy to understand.

3. Page Analysis

(1) Page classification: Mini Program pages are divided into native pages and hybrid web pages. During automated test analysis, the two types of pages should be processed separately. For native pages, you can accurately locate page elements and grab page controls; for hybrid web pages, you need to customize a special automated testing solution.

(2) Page modules: Mini Program pages can be divided into several functional modules. In the process of designing automated test requirements, it is necessary to decouple each module to the greatest extent and write test cases by module. In this way, even if it is changed later, it only needs to be modified for the module to minimize the impact.

(3) Page jump: There will be many jumps between the pages of the applet, and the jump relationship needs to be sorted out clearly in the process of test case design.

3. Analysis and design of automated testing framework

1. UI automation test framework analysis and design

        The UI automation testing framework simulates user operations on the page, including clicking, sliding, switching pages, jumping pages, etc. It is necessary to identify and locate the page elements, and deal with page jumps, page switches, and message pop-ups accordingly. There are many page automation testing frameworks, such as selenium, appium, minium (WeChat applet automation testing framework) and so on. In this paper, the author uses Appium, uses Appium to connect Pycharm and the mobile phone port, and realizes the function of controlling the small program on the mobile phone terminal with a test script.

Factors to consider when designing script architecture:

(1) Small program testing and UI automation testing frameworks should be separated and cannot be generalized.

(2) The test script is used across platforms and is compatible with different application systems.

(3) The test script module should have extremely low coupling. The update of a module should not involve modification in multiple places, and the maintenance should not be too difficult.

(4) The program and data are separated to improve the reusability of scripts.

In summary, the author writes the test script according to the function block. For example, enter the applet module, enter the simulated home appliance module, enter the home page of the mall, enter the discovery page, enter my page, etc. And the script design is divided into three levels: public method layer, module use case layer, and use case execution layer. as follows:

  1. Public method layer: store common files and functions, such as HTMLTestRunner, etc.
  2. Module use case layer: Design by function and module, use unit test model, each function block is independent.
  3. Use case execution layer: load test cases, execute test cases, and generate test reports.

2. Analysis and design of interface automation testing framework

The interface test is to simulate the user to send a request to the background, and the interface test can be realized by using Postman, JMeter and other tools. Here, the author adopts the interface automation testing framework of JMeter+Ant+Jenkins to realize the automation testing of the interface. JMeter is used to write scripts for interface testing, simulating small programs to send requests to the server. JMeter can use assertions to determine whether the interface returns are correct, and can issue forward and reverse tests without relying on the front-end page. Ant is a code compilation tool, which can compile code that the system cannot recognize into recognizable code, and is a test script generation tool. The main function of Jenkins is continuous integration, scheduled build tasks, and also has the function of email notification. The structure is as follows:

 4. Analysis and design of automated testing process

The automated testing process mainly includes five main steps: automated testing requirements analysis, test plan development, automated test script writing, automated test script execution, and test result analysis. as the picture shows:

(1) Automated testing requirements analysis

Use cases for software testing are written according to business requirements documents. After analyzing the business requirements, it is necessary to convert the business requirements into test requirements, and analyze which parts can be completed by manual testing and which parts need to be completed by automated testing. After the analysis, it is necessary to formulate specific test strategies and methods, and finally write manual test cases and automated test cases that meet the requirements.

(2) Make a test plan

After clarifying the test requirements, a test plan needs to be developed. For example, test scope, time, division of labor, environment deployment, etc. The test plan is formulated by the test manager, who flexibly arranges the division of labor among the members of the group and coordinates the project plans.

(3) Write test scripts

After the test plan is completed, the test engineer begins to write test scripts according to the specific needs of the project. After the test script is completed, it is sent to the project team for review to check whether the test scenario is covered and whether there is any room for improvement.

(4) Execute automated test scripts

After the test script is reviewed and there is no problem, it will enter the execution test stage. The environment needs to be prepared before the test. There will be reports and lon logs after the test runs.

(5) Analysis of test results

After the test report comes out, the test engineer needs to modify the test form to make the test results clearer. If there is a test failure, it is necessary to analyze whether it is a problem with the software itself, a problem with the script design, or a problem with the test environment.

References: [1] Deng Meiqi. Design and Implementation of Smart Home Mini Program Automated Testing [D]. Nanjing University of Posts and Telecommunications.

Guess you like

Origin blog.csdn.net/weixin_44686138/article/details/130304023