How to build an interface automation testing platform under Linux

Let’s learn today how to build an interface automation testing platform based on HttpRunner under Linux !

The environment that needs to be prepared in advance on Linux (the following is the environment when I built it):

1,Python 3.6.8 

2,MySQL 5.7

1: Download the HttpRunnerManager source code

We go directly to Github to download HttpRunnerManager and download it locally.

Github address: https://github.com/HttpRunner/HttpRunnerManager

2: Download is complete, decompress and transfer to Linux server

Three: Install the dependency packages in requirements.txt and enter the following command in the HttpRunnerManager-master directory:

1

pip3 install -r requirements.txt

Four: Create HttpRunner database on MySQL

The database created after connecting to MySQL through Navicat under Windows, named hrun

Five: Modify the configuration file and modify the DATABASES dictionary in the HttpRunnerManager/settings.py configuration file

1

vim settings.py <br>:wq

You can modify it according to the actual situation

Six: Synchronize database

Above, we just created a database named hrun, but there is no data table under this database. Now, we will synchronize the database to get the data table. You need to return to the root directory of HttpRunnerManager first, which is the HttpRunnerManager-master directory.

Generate data migration script:

1

python3 manage.py makemigrations ApiManager

Apply to db to generate data table:

1

python3 manage.py migrate

After the database synchronization is completed, we check it in MySQL and find that many new data tables have been added under the hrun database.

Seven: Create a background administrator user

Create a super user and enter the corresponding username, password, and email as prompted. This user can be used to manage background data

1

python3 manage.py createsuperuser

Eight: Start the Django service

1

nohup python3 manage.py runserver 0.0.0.0:8000 >hrun.log 2>&1 &

The logs of HttpRunnerManager running in the background will be output to hrun.log.

Nine: Log in to HttpRunnerManager

After starting the service under Linux, we will access and log in to HttpRunnerManager under Windows. We need to check whether ports such as 8000 are open.

If the environment is built on a cloud server, you need to add security group rules, otherwise you may not be able to access it.

Backend management : http://ip address:8000/admin/

Registration interface : http://ip address:8000/api/register/

The background operation and maintenance management login interface is as follows:

Enter the background user created in the previous step to log in to the background. The interface after login is as follows:

The HttpRunnerManager user login interface is as follows:

The main interface after the user successfully logs in:

Ten: Modify the style

1

2

cd templates/

vim base.html

In the templates/base.html file, line 23 needs to be modified. 

http://cdn.amazeui.org/amazeui/2.7.2/css/amazeui.min.css 

Replace with http://cdn.bootcss.com/amazeui/2.7.2/css/amazeui.min.css 

After the replacement, refresh the page again and the interface style will be normal. The final interface effect is as follows:

In HttpRunnerManager, asynchronous execution, scheduled tasks, task monitoring and other functions require the establishment of RabbitMQ message middleware, etc.

After practicing 30 practical projects of interface automation testing in 7 days, 28K people joined the byte testing position. [Automated testing/interface testing/software testing/performance testing/Jmeter]

Finally, I would like to thank everyone who reads my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, if you can use it, you can take it directly:

Insert image description here

This information should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey. I hope it can also help you!   

Guess you like

Origin blog.csdn.net/qq_48811377/article/details/133207361