What should an interface automation framework be built into, and how much content should it contain? There is no right answer to this question, because it depends on your project and what problem you want to solve with the framework.

Of course, I won’t go into the discussion here, but I’ll go back to interface automation and talk about what you should at least have.

First, the choice of programming language

If you have a special request to use a certain language, you don’t have much choice. My personal preference is to use Python unless specifically requested.

I have participated in the automatic development and maintenance of interfaces based on Java language before, and testng is used as the framework. Although the team leaders have tried their best to maintain the framework, it is still not as cool as Python. Maybe this is also a habit, but I learned Python first, then Java.

I remember the leader said that in order to synchronize the development language of the test with the development, so we switched to Java development. But again, if there’s no specific requirement, I’m going to embrace Python.

As a digression, is it enough to know python? Maybe in the past, but certainly not now. Java is still something to learn, and if you look at what most companies are developing in, it’s Java. It doesn’t hurt to master a few major development languages anyway.

Second, the selection of unit testing framework

Now that the language is decided, the unit testing framework is easy to choose. I am sharing in Python, so I have to mention unitTest pytest.

Unittest is python’s own unit testing framework, while PyTest is a third-party testing framework. Give the conclusion directly, use PyTest, advantage

Duo duo, plugin ecology is rich, who uses who knows. Enclosed pytestThe official documentationBut in English.

But it is still recommended to see more, write more, experience more.

I am writing a series of pyTest official documents. I have already written some of them. If you are interested, please check them out.

Third, good at excellent third-party library

The framework defines PyTest, so you can use it in conjunction with a number of excellent open source libraries to implement your own requirements. Here are some common ones:

  1. Requests, proxies, and more are available here in Chinese.
  2. Pymysql: You will be much more comfortable with the mysql interface test.
  3. Allure: It’s a test report. You can actually do interface testing without it, so if you want a nice test report, go for it. . . Third party library really many, not one list, to be good at search.

The basic structure of interface automation framework

That’s it, and you have the framework. As for the structure in the end, or because of people, projects, how to suit how to come.

The structure in the picture is not the one I am currently using in the project, but these are the basic structures, and their uses are as follows:

  • Conf: You can put configuration files here, such as database link information, interface domain name, etc.
  • Interface: This is where you put the test cases, and then you can split the modules further depending on your project needs
  • Report: Optional, if yes, you can put the generated report here
  • Util: I can write some public methods here

This is just a hint, whatever you name it, whatever fits.

At present, there are many more frames in the project. After all, there are several businesses in the project, and then there are all kinds of problems that need to be solved by the framework. Naturally, there will be more things.

This article only provides ideas, for the partner who wants to build interface automation framework reference, have a question can leave a message or private letter to me, of course, the most direct recommendation is to search, after all, this is an important skill to write code!!

The points to be aware of when writing an interface automation case will be shared next.