A thorough understanding of automated testing [Practice Summary], it is recommended to collect~

1. Basic knowledge of automated testing

What is automated testing

1. Change the human-driven test behavior to machine execution. Through the designed test case, the machine will automatically operate it according to the execution steps of the test case, output the results, and compare them with the testers.

2. Automated testing often uses some testing tools or frameworks to write automated test cases to simulate manual testing.

3. Automated testing can greatly save manpower, time and hardware resources, and improve testing efficiency.

Advantages of automated testing

1. The automated test tool can prepare a large amount of test data as needed.

2. A large number of test cases can be prepared using relevant scripting techniques.

3. The test results sometimes need to be processed accordingly.

4. It can quickly compare a large amount of data or data formats.

Disadvantages of automated testing

1. Compared with manual testing, automated testing has relatively high requirements for the ability of testers.

2. Automated test cases need to be updated according to version iterations, which has a certain maintenance cost.

3. Automated testing cannot be expected to find more new bugs. Automated testing can find far fewer defects than manual testing.

4. The output value of automated testing often lies in long-term regression testing, and its role in the short term may not be obvious.

5. Automated testing cannot improve the effectiveness of testing, it can only be used to improve the efficiency of testing.

Misconceptions about automated testing

1. With automated testing, manual testing is no longer required.

2. Automated testing For some tests such as localization testing, user experience testing, and exploratory testing, the construction of the test environment cannot completely replace manual testing.

3. Automated testing is the operation of the product. There must be a certain basis for manual testing of the test points. Automated testing and manual testing complement each other.

4. Automated testing does not only refer to automated running test products, data processing is also a very important link.

Prerequisites and principles for automated testing

1. The project cycle is long, and the demand is stable and has not changed in the near future.

2. Front-end development does not need to modify pages many times, and there are no defective modules left behind.

3. Automated test scripts can be reused, and regression tests are performed more frequently (due to the large number of modules, the scope of regression tests is temporarily limited to the main process of the module).

4. Manual testing is difficult to implement, and it is necessary to run the same test cases and a large number of repetitive tasks on multiple platforms.

5. Early automation implementation should avoid extremely complex modules

How to implement automated testing

1. Obtain information and test requirements analysis: grasp the overall system architecture and design, and analyze the test requirements of the system.

2. Design: design test cases, and select the test cases that need to be automated.

3. Implementation: Write, debug and implement test scripts.

4. Execution: The process of executing the script requires continuous analysis of exceptions in the execution process.

5. Analysis of test results: analyze which ones are bugs and which ones are problems of the test framework itself.

6. Maintenance: Automated test script maintenance is a difficult and necessary problem to solve.

7. Summary: Summarize the input-output ratio of automation practice in the process of automated testing.  

Hierarchy of automated testing

1. The higher you go, the closer you are to QA, business/end users, and the lower you go, the closer you are to development.

2. The higher up, the slower the test execution; the lower down, the faster the test execution.

3. The higher you go, the higher the test cost (the more time-consuming, the more vague the failure information, and the harder it is to track), the lower you go, the lower the test cost.

At the same time, I have also prepared a software testing video tutorial for everyone, which is placed at the end of the article. If you need it, you can watch it directly, or directly click on the small card at the end of the article to get the information document for free.

2. Automated testing tools and frameworks

Common automated testing tools

Automated testing tool development language: Java, Python, etc.

Basic Test Tool

(1) Unit testing: junit (java), unittest (python)

(2) Interface test: httpclient (java), restassure (java), request (python)

(3) UI testing: selenium webdriver (web), appium (app)

Common automated testing tools

(1) Interface test: Jmeter, soapui, postman

(2) UI testing: katalon, Robotframework, Android

Automated Test Script Technology

1. Linear script: recording, playback

2. Structured script: contains instructions to control script execution, supports sequence, selection and loop 3. Shared script: can be used by multiple test cases, and scripts can call each other

3. Data-driven scripts: Data-driven scripts store test input in separate files, and only control information is stored in scripts

4. Keyword-driven script: Keyword-driven script is actually a logical extension of the more repetitive data-driven technology, that is, the execution steps (operation, operation object, and operation value) of the test case are stored in the file and executed directly

Fundamentals of automated testing operations

1. Interface automated test operation

(1) Simulate request url and message, prepare test data, capture packets to obtain interface information, analyze the interface, with or without documentation

(2) Simulate the client sending HTTP requests (get, post)

(3) Simulate the client receiving the return message from the server

(4) Verify that the returned results meet expectations

2. Operation of UI automation test

(1) Locate page elements (findelement, findelements) by id, name, xpath, cssSelector, etc.

(2) Perform corresponding operations on the positioned page elements (click, input, etc.)

(3) Make a comparison between the result after the operation and the expected result (assert)

Basic principles of automated testing tools

Selenium (parse front-end code and control browser)

 

PO mode for automated testing

1. In the PO mode, it is abstractly encapsulated into a BasePage class, which has a property that only implements webdriver instances

2. Each page inherits BasePage, manages the elements in this page through the driver, and encapsulates the operations in the page into individual methods. TestCase relies on the page class to implement the corresponding test steps

 

automated testing framework

1. Keyword driven

(1) Divide the test case into four different parts. The first is the test step (Test Step), the second is the object in the test step (Test Object), the third is the action (Action) performed by the test object, and the fourth is the data required by the test object (Test Data).

(2) Combine data with keywords to describe how to perform the test. That is, the steps in the test case script are extracted and placed in an independent data file, which becomes a simple way of writing. This approach has the advantage of being data-driven, while allowing non-programmers to create tests.

(3) The keyword-driven model is based on the data-driven approach, and the keyword-driven file contains instructions (keywords), not just data.

(4) This test framework can generate a large number of test cases with very little code. The same code is reused while using the data table to generate each test case.

2. Data-driven

(1) Read the input test data from a data file (such as Excel file, Xml file, Json file, database, etc.), and then pass it into the written test script through variables.

(2) The reading of data files, test status and all test steps are written into the test script; the test data is only included in the data file, not in the script, and the test script is just a "driver", or a transmission Mechanism of data.

(3) The data-driven method is mainly used in scenarios that require different data to ensure test coverage, such as the business logic of the system under test is fixed or changes little, that is, the test case steps are fixed, but the required test data It is a changing situation. Generally speaking, the data is stored in an external file or database, and is automatically obtained at runtime. That is, the test framework must support the separation of data and scripts, and one test script can drive the execution of multiple similar test scenarios.

(4) This framework intends to reduce the total number of test scripts required to execute all test cases, and data-driven requires very little code to generate a large number of test cases.

3. Selection and construction of automated testing framework

Technical solutions

Selenium(Webdriver) + Python(unittest)+ cx_Oracle + HTMLTestRunner

Selenium's WebDriver is an open source tool. Using the relatively simple Python language for automated testing is more practical in terms of personnel learning costs, and the learning time is short, which has advantages.

The unittest unit testing framework that comes with Python can easily implement tasks such as the design and execution of automated use cases and the management of automated use case suites. Python is a pure object-oriented language, and it can also be transitioned to Java + Selenium for richer automated testing in the future; in addition, Jenkins can be selected as the continuous integration server to perform automated smoke testing with the Python + Selenium solution.

This solution uses the Page Object design pattern to separate pages, use cases, and data. In this way, the test case can pay more attention to the business rather than the interface details, improve the readability of the test case; reduce code redundancy and increase the reusability of the method.

environment selection

According to the discussion results of automated testing requirements of the test group, use automated testing technology to do regression testing in uat and stage environments. (Make sure that the environment can be used normally before execution)

Due to the frequent release of UAT and stage environments, which affect the debugging and scripting of the automated test framework, apply for a stable environment for debugging and writing.

Automated testing process

(1) Select the module

(2) Select a use case (main process use case)

(3) Write the operation method by page

(4) Write use case process scripts by use case

(5) Write data query methods according to use cases

(6) Execute use cases

(7) Output report (later expansion, adding execution logs and exception screenshots to track defects).

To sum up, when the script content is written and the business requirements and test requirements have not changed, just perform the last two steps. Check the content of the report. If a defect is found, it is necessary to reproduce the defect according to the content of the use case and submit it to the ZenTao management system.

Subsequent maintenance

(1) Changes in business requirements

When the business requirements change, the use case of the changed content should be skipped when the use case is executed, and the script and use case should be adjusted accordingly after the changed content is launched. After the adjustment is completed, it needs to be executed again to ensure the stability of the use case.

(2) Refactoring of the module under test

When the refactoring of the module under test is completed, it is necessary to execute the automated test case of the module to check whether it is executed normally. If there is no problem, no adjustment is required. If there is a problem, it needs to be debugged and solved in time.

(3) Technical changes

With the continuous optimization and expansion of the automated testing framework, the basic modules and encapsulated pages will also change accordingly. Furthermore, automated testing needs to be performed regularly to ensure the stability of the framework after tuning and expansion, so as to ensure the normal progress of regression testing.

resource allocation

(1) Environment:

a. The project environment is similar to that of the online project. It is published independently. The content of the version is relatively stable. The database is independent and will not be affected by other environments.

 b. Local environment, win7&win10 Chrome 72 32bit.

(2) User: Independent user, the authority should be adjusted as high as possible, so as not to be affected by user authority to access certain function points, and to reduce the omission of use cases.

(3) Personnel: Establish an automated testing group, ideally with 3-4 personnel, test development, intermediate and senior automated testing engineers, and junior automation engineers.

(4) Training: Training for junior automation engineers, design framework and packaging drive, etc.

Fourth, automated testing is implemented in stages

1. Build the basic framework and complete the automated test demo of a module

Adopt the Page Object design pattern to encapsulate and isolate page elements, use case processes, and data, and re-encapsulate the webdriver in the common module or basic module, and automatically generate test reports to analyze the results of automated test execution.

2. According to the framework of the basic version, expand the scope of testing

Select functional modules suitable for automated testing, write scripts, use cases, etc. according to the basic framework ideas, and then expand the framework to realize data-driven, scheduled test execution, sending report emails and other easy-to-use non-core functions.

3. Regression tests covering most modules

According to the coordination of resources such as personnel, the automated test cases are extended to the extent that most of the module regression tests are covered. Regression testing is completed by performing automated testing to achieve the purpose of improving the efficiency of regression testing and reducing the manpower requirements for regression testing.

summary

Automated testing technology has certain advantages in modern testing technology, but automated testing is not necessary in any case. Appropriate or cost-effective investment requires us to introduce automated testing at the right time, so that manual testing and automation The test achieves a perfect combination.

Watch free video tutorials at:

A very perverted but allows you to quickly master automated testing (Web/interface automation/APP/Selenium/performance testing, etc.) Automation/APP/Selenium/Performance testing, etc.) magical methods totaling 100 videos, including: [Automated testing] How to design interface test cases? 、【Automated Testing】Automated testing framework design ideas, a full set of software testing materials and learning routes, etc., for more exciting videos from the UP master, please pay attention to the UP account. https://www.bilibili.com/video/BV1hj411z71j/?vd_source=74d0257ec7066cc4f9013524f0bb7013At the right age, choose the right position, and try to give full play to your own advantages.

My road to automated test development is inseparable from the plan at each stage along the way, because I like planning and summarizing, so my friends and I spent a period of time organizing and writing the following "Software Testing Learning Route", which is also Organized a lot of [network disk resources]

 PS: How can I get it? It's very simple, just click the small card below to get it for free!


 

 

Guess you like

Origin blog.csdn.net/HUA1211/article/details/132249488