How can testers efficiently design automated test frameworks?

Regarding the benefits of testing frameworks, such as fast regression to improve test efficiency and test coverage, we will not discuss them here. Here we mainly discuss what the automation framework includes and how to design a test framework.

What is an automated testing framework?
It is a collection of tools consisting of one or more automated testing basic modules, automated testing management modules, and automated testing statistics modules. Taking the common front-end UI test as an example, a test framework roughly includes modules such as test objects, test components, basic classes and functions, tool classes, test data, exception handling, test logs, assertions and test reports. When designing the test framework, we should try our best to combine these modules organically, so that the script can be effectively organized and applied coherently, so as to improve the maintainability and readability of the test script.

Due to the diversity of application system technologies, almost no test framework can be applied to multiple projects and reflect its due value. Therefore, in general, we need to customize our test framework according to the project itself. Commonly used data-driven, keyword-driven and a mixture of the two

Data-driven (DDT) - If the business logic of the system under test is fixed or changes little, we can use data-driven to ensure test coverage through different data. Usually data is stored in external files or databases. Obtained automatically. It is characterized by the separation of data and test scripts. Based on the modular test library, one driver script can execute multiple similar tests, and it is very easy to create new tests.

Keyword-driven - Combine data with keywords to describe how the data will be used to perform the test. This approach has the advantage of being data-driven, while also enabling non-programmers to create new types of tests.

Design framework ideas
a. High cohesion and low coupling: High cohesion means that each module completes its own functions as independently as possible without depending on the code outside the module; low coupling means the complexity of the interface between modules and modules, such as in a class Minimize calls between methods as much as possible, otherwise changes in one method will affect another method that calls it.

Separation of scripts: Objects, test data, and business logic are separated from each other and can be called flexibly. Front-end UI testing can yield obvious results. We can use the PageObject design pattern to realize the separation of objects and business logic, and use DataProvider to realize data business. logical separation.

Improve script reusability with simple modular design

If time is sufficient and the project supports it, testing can be performed in the following order: page object-function point-business logic-business process.

In terms of implementation: first test the underlying page operation object, verify the function points by calling the operation object and business logic, and then realize the verification of the business process by calling the business logic and combining function points. Different business processes are completely reusable for the bottom-level operation components and the function points of the middle layer, but the business logic invoked or the test data are different. The advantage of this is that the scripts are independent of each other, the code is reused, and it is easy to maintain. If there is a new business process, you can call the existing code to merge.

The basic method of encapsulation is
that some common methods can be encapsulated, such as log, assert, exception handling, file read and write operations, database read and write operations, saving page screenshots, etc., which can be directly called in test cases when needed.

How to conduct automated testing
Grasp the pain points of business testing work and leadership pain points, communicate more and communicate more, and give priority to solving the pain points of grassroots work. Believe that a good leader will see your sense of responsibility and dedication;

Invest more time and effort in technical options and feasibility studies of solutions. Some people are in a hurry and do it quickly in the early stage. If you go in the wrong direction at the beginning, you will end up losing more than you gain;

If it is a more complicated solution, try to separate the front and back ends as much as possible to ensure that each module is independent, integrated, decoupled and not disassembled, flexible and scalable, and ready for the next big show.

Finally: In order to give back to the die-hard fans, I have compiled a complete software testing video learning tutorial for you. Friends can get it for free if they need it [Guaranteed 100% free]


 

                                How to obtain the full set of materials: Click the small card below to get it yourself

Guess you like

Origin blog.csdn.net/2301_76643199/article/details/132148637