Python offers several robust testing libraries, from unit testing and mocking for integration tests to security, load, and UI testing. We have reviewed several libraries and have chosen to share these for their ease of implementation, ease of use, and community contribution/active maintenance over time. As you read, you’ll learn about each of the libraries, how they work, where to fit them in your toolchain, and where you can learn more about each.
Get TestRail FREE for 30 days!
There are many unit testing tools available for Python. One tool that meets the needs of unit testing, checking code coverage, and checking for Python standards is PyBuilder. PyBuilder can be used as a tool to write and develop unit and integration tests using TDD. PyBuilder offers frequent updates, complete documentation, and tutorials for installation and usage, as well as plugins that work with existing python test tools. I have used this tool to do test driven development and run tests and code in Python, while analyzing output. For testers, setting up a local PyBuilder installation and then doing some simple code exercises using test-driven development, may be a great way to learn more about unit test development and better understand how unit and integration tests complement one another. One resource to learn TDD using these tools is Python Koans.
Selenium Webdriver is one of the most well-known and stable tools in the tester’s toolbelt for UI testing. Webdriver has bindings for many languages, and Python is no exception. Selenium-Python can be used in headless environment, and can be used with unittest frameworks that don’t require Behavior or Acceptance Test Driven Development to be useful.
For testers who want or need to implement an ATDD solution in Python, the Robot Framework is a well-maintained project with various outreach and support including social media, documentation, videos, and tutorials. Python Behave is a well documented port of the BDD tool Cucumber. Releases have become less frequent over the past year; however, the tool enjoys support from google groups and main developers. Since it is written in Python, it is also easy to customize, which can be good for small implementations.
Many developers and testers want tools that they can use to run active or passive security scans on their software. The Open Web Application Security Project (OWASP) is an open source security project that maintains one of the most popular security scanning tools, the Zed Attack Proxy (ZAP). Known as OWASP ZAP, the project has a Python API that can be used to incorporate security scans into continuous integration suites.
So what does this mean? For testers, it is a great opportunity to work with the development team to implement tools, learn more about Python, and gain an overall product benefit. Learning OWASP ZAP is accessible, with a tremendous amount of documentation and support, including YouTube videos and tutorials. Testers looking to learn application security will find the toolset available in OWASP ZAP to be very extensive, with additional plugins available for use.
There’s a Library for That
The Python ecosystem is vast, and there are hundreds of tools available for testing. If you are looking for a tool to do a testing job, it is likely that there is at least one existing tool under active development, which means an active GitHub or PyPi repository, extensive documentation, and a supportive user community. Because Python is an open-source language, testers who wish to use Python tools can also make contributions to these tools, or even build their own. The Python community is friendly, and tools with active authors and communities are generally willing to answer questions and point you in the right direction as you learn and implement them into your toolbox. Investigate the libraries in this article, and continue your research into the variety of test tools available for Python.
Python Koans: https://github.com/gregmalcolm/python_koans
Mockito for Python: https://github.com/kaste/mockito-python
Selenium-Python Versioning: https://pypi.python.org/pypi/selenium
Robot Framework: http://robotframework.org/
Python Behave: http://pythonhosted.org/behave/
OWASP ZAP: https://github.com/zaproxy/zap-api-python
Python Testing Libraries: https://wiki.python.org/moin/PythonTestingToolsTaxonomy
This is a guest posting by Jess Ingrassellino. Jess is a software engineer in New York. She has perused interests in music, writing, teaching, technology, art and philosophy. She is the founder of TeachCode.org
Test Automation – Anywhere, Anytime
- How Leading Teams Integrate Test Automation with TestRail Test Management
- What Continuous Delivery Means for Testers, QA Teams and Software Quality
- Session-Based Test Management Software with TestRail
- Consider “Reasonable” UI Test Automation