Learn the basics of Python's pytest framework and learn to prepare for it

Source: Internet
Author: User
Tags prepare

Test practitioners Learn what Python should know:

The first is the variables and data types, followed by a list, a dictionary, and some Json processing, and then the loop judgment and the functions or classes. The Focus:

1. Cycle judgment and the dictionary this is the point.

2. Functions and classes, classes of learning this piece takes more time to learn its integration, encapsulation, polymorphism, and so on, this is a continuous accumulation of the process, first clear the front of things, and then learn how to use the method of the function to deal with these comparative basis of the content of the Python outline learning content see another article sweep the QR code below E-commerce Project live two, Python interface Automation API testing is different from UI automation testing, which focuses on the business logic layer of the system architecture, or the logical relationship of multiple or two modules, with a focus on logical relationships.

Do the preparation before the interface test

1. Interface documentation

2. Knowledge of HTTP protocol

3. Familiarity with the business

What Python needs to prepare for interface automation

1. python3+ third-party library requests+pytest Framework, the need for the environment are ready to choose the reason for pytest this framework

1). Very easy to use, easy to get started, rich in documentation, there are many examples in the document can refer to industry dynamics, technical exchanges,

2). Ability to support simple unit tests and complex functional tests

3). Support Parameterization

4). Some tests can be skipped during the execution of the test, or marked as failed for some cases that are expected to fail

5). Case with support for duplicate execution failure

6). Support for running test case written by nose, unittest

7). Has a number of third-party plugins and can customize the extension

8). Easy and continuous integration tool integration

2. Preparation of the interface documentation

1). Interface documentation contains at least four parts

1, the requested interface 2, the request Method 3, the request parameter 4, the request returns the result

2). No interface documentation use the Grab Kit tool to get information

3). Interface testing includes interface automation and manual interface testing

3. Implementation of the interface Automation premise: The purpose of the clear implementation is to do single-interface monitoring or trading process monitoring, or in the test environment to cover all the interfaces, or interface automation testing for online services or offline testing environment services For example: Now to do is the monitoring of the single interface, The purpose of monitoring is only to ensure the availability of the interface, it is possible to prove that the interface is available. Therefore, the design of interface testing based on different purposes has different test points, such as single-interface monitoring, only need to design positive use cases can be, to prove that the interface is through. Because there are too many tests on the wire, it is easy to produce very much dirty data. If in the test environment to do the full coverage of each interface, then the positive use case of each interface, the exception use cases are to be covered, if the use case is particularly much to determine the scope of some of the interface use cases according to the focus of the function of the selection of an optimal set of the interface use cases as a collection of attention points: If you need some cache data either to write dead or to be long-term, to avoid an interface where the use case needs to rely on other interfaces, the reason is that if the dependent interface fails to avoid the dependency of the interface execution is the last of the failure: the environment, the interface documentation, the design of the use case, and the purpose of the interface can be started

4. Actual interface Automation code writing instructions first locate the requested URL and interface address according to the interface document plus the second part of the host request parameter Part III if there is a header file to put the head file in, if there is no header file can ignore the request for the fifth of the corresponding results to judge The corresponding results are judged by six parts of concern:

1). Return Status Code check

2). Check the key parameters returned by the interface

3). Interface integrity is the correct level of the relationship

4). The integrity of the parameters

5). Inspection of special parameters

6). Functional check sweep below QR Code e-commerce Project Live

Summarize the preparation of the environment first, then do the purpose of interface automation, design test cases based on the purpose, design the test cases to determine the degree of validation of the return results, these are determined to follow the pytest template to write the use case.

3.Jenkins Continuous Integration first prepare a server for the Jenkins continuous integration, then go to create a task, create a task to configure the necessary information such as git source, and then execute some of the commands after the build of some actions, such as sending mail and so on when creating a task with git source, ssh this way , you need to set Sshkey, and then the frequency of the execution of this task, generally there are several ways: the first cycle of project construction, it is not concerned about whether your code source is a change, it is scheduled to perform the task at regular intervals, the second is the form of ICM, it is time to check the source code changes , if the source code has changed, it is to perform the task of the set, if the source code is not changed and not executed, there are other ways, according to the actual needs to choose the corresponding way.

All right, learn the basics of Python's pytest framework and learn how to prepare for the introduction here, I hope to give beginners some inspiration, if there is nothing to understand, you can add QQ Group: 862672474, Welcome to share the discussion ...

Learn the basics of Python's pytest framework and learn to prepare for it

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.