Ali is on the second side, it turns out that my understanding of automated testing is too shallow

How to use Python to implement automated testing

If you join a new company and the leader asks you to carry out automated testing, as a newcomer, you will definitely be in a hurry. How will you implement automated testing? The senior test architect will tell you how to implement automatic kan testing. This topic is mainly divided into the following parts:

1. What is automation?

2. What is hierarchical automation?

3. How to use Python to realize automated testing?

4. Is RobotFramework automation suitable for your situation?

5. What is the routine maintenance for the successful implementation of automation?

  1. What is automation?

There are many people who have done automation for a long time but don't even know the concept of automation. Such people are also very sad. They do this kind of profession but don't even know the most basic concepts. Let me list them as follows (quoted from "Software Evaluator Page 69"):

Definition of automated testing:

Automated testing is the automatic testing of software products through testing tools or other means in accordance with the predetermined plan of the test engineer. It is an important part of software testing, and it can complete many testing tasks that cannot be completed manually or are difficult to achieve. The correct and reasonable implementation of automated testing can quickly and comprehensively test the software, thereby improving software quality, saving money, and shortening the product release cycle.

The above is the concept of automated testing standards. In a nutshell, it is nothing more than replacing labor with automated means, but not completely replacing labor. Here I have to point out a misunderstanding. Some people do not understand the meaning of automation, especially some leadership. I believe that automation is omnipotent. As long as automation is done, functional testing can be completely liberated. Even if the automation script is written smarter, it is impossible to completely replace manual work, and the manpower consumed by automation is a great expense for the entire project team. So automated testing is not a panacea.

After the concept of automated testing is introduced, we will also introduce the types of automation included. The most popular types of automation on the market include the following types.

1. UI automation

2. Interface automation

3. App automation

4. Unit automation

5. Automated testing tools (test development aids)

There are many types. Do all types of automation have to be carried out in the project? This leads us to a new point of view, what is hierarchical automation?

  1. What is hierarchical automation?

First picture

Let me first talk about the misunderstandings of automated testing that I see in my work:

1. After the automated test scripts are completed, a large number of test cases become invalid due to product updates. As the team is busy developing new functions, when more and more invalid use cases accumulate, these test cases gradually lose their maintenance. It may be easier to develop these use cases when students are there.

2. A large number of automated test scripts did not find any problems, and there were still problems after going online. In the test, we mainly test the normal process, but the faults online are all abnormal processes.

3. The code quality problem is serious. Many people write unit tests that just construct an input and then check the return value. The result is that the test passes but the problem is missed.

4. Repeated wheel manufacturing. A large number of teams are developing their own automated testing frameworks, but in fact they just tailor and perfect various open source frameworks.

Hierarchical testing includes the following levels:

1. Unit test: A small piece of code written by the developer to check whether a small and clear function of the code under test is correct. Generally speaking, a unit test is used to determine the behavior of a specific function under a specific condition (or scenario).

2. Integration test: also called assembly test or joint test. On the basis of unit testing, all modules are assembled into subsystems or systems according to the design requirements (such as according to the structure diagram) for integration testing. Here we can think of it as interface testing.

3. System testing: As an element of the entire computer-based system, the software to be tested is tested in conjunction with other system elements and environments such as computer hardware, peripherals, certain supporting software, data, and personnel. Here we can understand it as UI testing. In addition, a comprehensive rule is found, the earlier the repair cost is lower.

  1. How to use Python to achieve automated testing?

In terms of language, Python's automation is nothing more than calling the corresponding encapsulated API.

In many automated testing frameworks, there are corresponding packages for languages. But there are so many, automated testing is nothing more than to be divided into these types, I pointed out the corresponding automated testing framework.

1. UI automation

web automation: selenium

GUI automation: autoit

2. Interface automation

urllib2

requests

3. App automation

appium

4. Unit automation

Related to language

Seeing the above framework, everyone will definitely feel that learning is automated. You must not only be familiar with the basic framework content knowledge, but also have a considerable understanding of the language in order to truly realize automated testing. So it leads to RobotFramework, an automated testing framework to be introduced today.

  1. Is RobotFramework automation suitable for your situation? Problems faced by automated test development

The version iteration speed is very fast, the iteration time is very short, and the automated test development is too short. The development cost of automated test development framework is too great. Especially for start-up teams, the human cost of developing a framework is too high.

Actual projects, especially large-scale projects, usually have very complex functions, which is also a challenge for building automated test cases.

In summary, there are certain limits to the size of the department, and the methods and methods of automated testing are truly realized.

For large-scale testing departments, if you have strong development capabilities, you can consider building an automated testing framework, but for small teams, you still have to choose a lightweight and mature automated testing framework.

RF features

1. It is easy to use, adopts tabular grammar and unified test case format.

2. It can be completed using keyword-driven, data-driven and behavior-driven development (BDD).

3. Good reusability, you can use existing keywords to combine new keywords; result report and log

Capture HTML format, easy to read. Platform and application relevance.

4. Easy to integrate, providing a command line interface and XML-based output files.

5. Easy to integrate with version management.

6. The keywords are wordized and easy to understand.

Architecture diagram of RF implementation:

RF code example:

Automated testing can be solved with only one framework of RF

The RF automated testing framework is an automated testing framework that combines keyword-driven and data-driven automation. From the perspective of automation, this integrated automated testing framework is the overall trend discovered by the current automation framework. In particular, simply using a framework at work cannot meet the needs of work.

  1. How to implement automation and how to do routine maintenance?

How to implement automated testing in actual work is also a big pain point. Often automation has done a lot, but it can’t solve the actual problems at work. The value of automation is nothing more than two aspects. One is auxiliary function testing. Data, the second is to do smoke testing and regression testing. If these two points are not achieved, automated testing will not be able to achieve real applications, and it is impossible to save labor. In the actual work process. There is also a very important problem. When the automation is first done, it is very important to lay the foundation. If the foundation is not well laid, many problems will be discovered in the whole framework in the later stage, and this framework will often be abandoned in the end. . The choice of the framework and the development of the framework are very important. It is required that automated testing must be done in the short term. It is conceivable that automation cannot be done in a short time. If the architecture is not well designed, the possibility of rework will be greater in the later stage. So this also determines that the initial stage of automation is not blind, and the foundation must be made.

The same also leads to our focus today, RobotFramework automated testing framework, a mature automated testing framework, and behind this framework is the Python language as an extension, all things that Python can achieve can be achieved in this framework. There are many frameworks. From the perspective of choice, find a mature framework and focus your work on managing test cases. This is the highest level of automation. It is also the value and meaning of the most appropriate work. It is a waste of time for everything that promotes high technical content without a framework close to the work.

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 testing technology.

In the interview season of the Golden 9th and the Silver 10th, the job-hopping season, 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.

For software testing friends, it should be the most comprehensive and complete interview preparation warehouse. In order to better organize each module, I also refer to many high-quality blog posts and projects on the Internet, and strive not to miss every knowledge point. Friends relied on these contents to review and got offers from big factories such as BATJ. This warehouse has also helped many learners of software testing, and I hope it can help you too!

May you and I meet and you will find something! Welcome to follow the WeChat public account: [Sad Spicy Article] Receive a 216-page software test engineer interview book for free. And the corresponding video learning tutorials are free to share!

Guess you like

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