Analysis of Python testing framework process Configuration

Source: Internet
Author: User
Tags dedicated server version control system

For some developers engaged in project development, such as early adopters, they need to discover and run tests on Large Code bases in a unified way. In order to develop a Python testing framework, this Python testing framework is still widely used.

Currently, the testing frequency is getting higher and higher. Many teams have adopted continuous tests, that is, each checkin of the team's version control system must run a project test. As testing-driven development methods become increasingly popular.

Many developers write and run tests for the module before writing code for the new module. If the test runs for a long time, it will seriously affect the productivity of developers. Therefore, it is very beneficial to run the test with as many computing capabilities as possible.

For small-scale projects, this may mean that multiple test processes are run using all the CPU cores of the computer. For larger projects, you need to configure a complete test computer group, either using a dedicated server to run the test in parallel or using the free time of all Developer workstations.

In terms of parallel and distributed testing, the three testing frameworks discussed in this article have significant differences: zope. the testing command line has a-j option, which specifies that multiple test processes should be started, rather than executing all tests in the same process. Because each process can run on different CPU cores, if you run-j 4 on a computer with four CPUs, you can run the test with four CPUs at the same time.

The nose project report says they have submitted Support for parallel testing to the project trunk, but generally users will not be able to try this feature until the next version. The py. test tool supports one multi-processing option (-n) and can run tests on multiple CPU cores like zope. testing. In addition, it provides management tools to distribute tests across the test server group.

Among the three frameworks, py. test seems to be ahead in parallel testing. Multiple -- tx options can be specified. Each option describes an environment or remote server for testing. In addition, it supports distribution tests for two completely different reasons! When -- dist = load is used, it uses a server group to run tests on multiple computers in the traditional way, reducing the test time.

However, when dist = each is used, it is complicated; it ensures that each test runs in every test environment available for py. test. This means that py. test can run tests on multiple Python interpreter versions and multiple operating systems at the same time. Therefore, if the project supports multiple platforms.

If you want the test solution to automatically support multiple platforms without writing scripts to copy the tests to different platforms and run them, this feature of py. test is very attractive. Customization and scalability the three test frameworks provide customization capabilities for individual users and the entire project. You can select the behavior and options of the test framework as needed.

In the Zope package, buildout that specifies the default option often calls the zope. testing module. This means that the developers running the test will get a unified result set. However, if the behavior selected at the project level cannot meet their needs, they can still specify their own command line switch.

The nose framework supports user customization through the nose. cfg or. noserc files in the user's home directory. You can specify the display mode of the test results in these files. For The py. test and nose frameworks, You can provide options for the entire project. The py. test Framework searches for the conftest. py file in the project it tests, and then finds the option for the entire project in this file.

For example, whether to detect and run doctest and which mode should be used to detect test files and functions. The nose framework looks for the setup. cfg file in the project scope, which is the standard way to provide information about the Python test framework), and then looks for the [nosetests] section in it.

In addition, py. both test and nose support plug-ins. The modules provided by these users can install new command line options and add new behaviors to the tools. However, the configurations and functions they provide are different. In the past, every Python testing framework used its own practices;

With the next-generation Python testing framework, you can provide concise practices and unified testing technologies. In the next article, we will begin to study the testing mechanisms implemented by each framework, that is, the technologies used to search Test Modules and test files. Please continue to read the next article.

  1. Introduction to Python system files
  2. How to correctly use Python Functions
  3. Detailed introduction and analysis of Python build tools
  4. Advantages of Python in PythonAndroid
  5. How to Use the Python module to parse the configuration file?

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.