简体   繁体   中英

pytest-cov get automation coverage from remote server

I'm using py.test for REST API automation using python request library.

How to get coverage using pytest-cov tool. I'm running the automation on build server and code is executed in application server.

When you run the py.test command to kick off your tests, you can simply add the pytest-cov arguments to the command.

For example:

py.test --cov mycode --cov-report html  # plus other py.test arguments

Replace mycode with the name of the package or module containing your code. This tells the coverage plug-in to report coverage stats specifically on that code.

That's the simplest way to run py.test . You can make things a little more sophisticated by adding a .coveragerc file . Also check py.test --help for more information.

The usual coverage tools are built for the much more common case of the measured code being run inside the same process as the test runner. You not only are running in a different process, but a different machine.

You can use coverage.py directly on the remote machine when you start the process running the code under test. How you would do that depends on how you start that process today. The simple rule of thumb is that wherever you had been saying, "python my_prog.py", you can say, "coverage run my_prog.py".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM