Automating Testing with Python: A blog that goes into the basics behind automated testing, and how Python can dramatically improve your productivity.
Sample Pyunit test: If you’ve never seen an automated test before, this will give you a basic idea of what Pyunit tests look like.
Real World Automated Testing: An interesting article about some experiences with automated testing in a real-world, professional environment.
Python Testing Tools Taxonomy: A good page for getting introduced to the entire ecosystem of testing tools available for Python. It also includes links to articles about specific tools.
Test Code Coverage: A good article that discusses the concept of code coverage (how much of your code is actually run by your tests) and some tools for measuring it in Python.
PyCon 2009 – Django’s Testing Infrastructure: An excellent presentation on how one Django developer created a “micro-framework” to make Django’s existing testing infrastructure more powerful, flexible, and easy to use.
There are a number of great resources that dive into the basics of automated testing, how to write better tests, and which tools to use. Here are a few:
Test-Driven Development with Python: This is a book that covers everything from setting up your environment for testing to using mock objects and integration testing.
The Hitchhiker’s Guide to Python! Testing Your Code: An extremely well-written tutorial by Kenneth Reitz, one of the core developers of Requests.
Python Testing 101: A great introduction by Dan Bader.
Automated Testing with Python: A blog that goes into the basics behind automated testing, and how Python can dramatically improve your productivity.
Automated testing is an important part of software engineering. It helps ensure that everything behaves as expected and provides a way to catch bugs before they make it into production.
Python is a great programming language for automating things, thanks to its diverse set of libraries and the ability to write scripts relatively quickly. This article will go over some of the basics behind automated testing in Python and how you can get started writing your own tests.
To follow along with this article, you should have Python 3.5 or later installed on your computer. You will also need pytest for this tutorial. You can install it with pip by running the command pip install pytest from your command line or terminal.
“If you don’t start with good tests, you’ll never have good tests.” Those words from a teacher of mine during my first software engineering course at university ring true to this day. While writing code for an application, it’s important to also write tests for your code. A test is a set of instructions that a computer program or automated machine can perform in order to verify that other components of the system work as intended.
Writing the tests before the code itself is a common method called Test-Driven Development (TDD). Although TDD has its advantages and disadvantages, I strongly believe that writing tests should be part of any software engineering project. In this post, I will give you an introduction on how to automate testing using Python and some common libraries.
Automation at Scale
It’s very easy to write some simple Python code to test small functions or classes in your applications. All you need is a function or class with inputs and outputs that you can easily test for correctness. However, once your application gets bigger and more complex, automating testing becomes harder and more time consuming. For example, say we want to build a web application that allows users to register on our website – we would need to write automated tests that assert our registration feature works as intended
The pytest testing framework helps you write tests quickly and keep them readable and maintainable – with no boilerplate code.
The Python Testing Tools Taxonomy: An extensive list of Python testing tools maintained by the community.
Write a Test-Driven Development (TDD) Python Calculator: A tutorial that walks through building a simple calculator in Python using TDD principles.
Python Unit Testing Tutorial: A guide to unit testing in Python that shows how to build testable applications, as well as how to write automated tests using unittest.
Unit Testing in Python: A guide that explains how to use the built-in unittest module for writing unit testing in Python.
Python Unittest Example: Learn the structure of unittest and how to create test suites, test cases, and do assertions with it.
Writing Tests for AWS Lambda Functions: A step-by-step guide for writing unit tests for your Lambda functions with the Serverless Framework and the Serverless framework’s built-in testing features.
Automate the Boring Stuff with Python: A free online book that goes over the basics of Python, and how it can be used for simple everyday tasks.
Google’s Python Class: Another free online resource for learning the basics of Python.
Python for Software Design: A free online book that goes through how to write software using Python.
Test-Driven Development with Python: A free online book about test-driven development in Python.
Full Stack Python: A collection of resources on all things web programming related in Python.