Jump to ratings and reviews
Rate this book

Testing Python: Applying Unit Testing, TDD, BDD and Acceptance Testing

Rate this book
Fundamental testing methodologies applied to the popular Python language Testing Python; Applying Unit Testing, TDD, BDD and Acceptance Testing is the most comprehensive book available on testing for one of the top software programming languages in the world. Python is a natural choice for new and experienced developers, and this hands-on resource is a much needed guide to enterprise-level testing development methodologies. The book will show you why Unit Testing and TDD can lead to cleaner, more flexible programs.

Unit Testing and Test-Driven Development (TDD) are increasingly must-have skills for software developers, no matter what language they work in. In enterprise settings, it's critical for developers to ensure they always have working code, and that's what makes testing methodologies so attractive. This book will teach you the most widely used testing strategies and will introduce to you to still others, covering performance testing, continuous testing, and more.

Learn Unit Testing and TDD—important development methodologies that lie at the heart of Agile development Enhance your ability to work with Python to develop powerful, flexible applications with clean code Draw on the expertise of author David Sale, a leading UK developer and tech commentator Get ahead of the crowd by mastering the underappreciated world of Python testing Knowledge of software testing in Python could set you apart from Python developers using outmoded methodologies. Python is a natural fit for TDD and Testing Python is a must-read text for anyone who wants to develop expertise in Python programming.

201 pages, Kindle Edition

First published July 3, 2014

11 people are currently reading
85 people want to read

About the author

David Sale

8 books

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
13 (23%)
4 stars
28 (50%)
3 stars
10 (18%)
2 stars
3 (5%)
1 star
1 (1%)
Displaying 1 - 13 of 13 reviews
Profile Image for Venkatesh-Prasad.
223 reviews
February 10, 2017
A good introductory book to unit testing, test driven development (TDD), and acceptance testing via behavior driven development (BDD) in Python. It relies on nose test runner to introduce unit testing and lettuce to introduce BDD. Definitely a book for folks beginning testing in Python or wanting a breezy introduction to testing tools in Python. Ideal for students toying with testing tools in Python.

Having used pytest myself, I figure the next edition of the book would benefit from using pytest instead of nose and also introducing property-based testing using hypothesis+pytest.
Profile Image for Jelena K.
13 reviews
October 7, 2014
This book is excellent for those, who don't have an experience in writing tests or have only basic knowledge. You will look at Mock objects, Requests, Lettuce and other python libraries. For example for me the new information about lettuce is like gold.

Book is very small, well written. For each library there is a lot of basic examples, practices. So if You don't have big experience - grab it.
Profile Image for Alejandro Teruel.
1,332 reviews255 followers
September 20, 2018
I agree with all the Goodreads reviewers to date (Venkatesh-Prasad, Jelena K, Arquero, Miguel Vargas, Artemis Pavel Karateev , Alex, Tihomir and Dgg32) in that this is a nice, short introductory and pragmatic book on a number of important practical and topical tools and techniques on testing Python programs in the context of agile development. It delivers on its claims in the introduction, which are well worth quoting extensively:
The book lets you get your hands dirty with the basic building blocks in testing, which are unit tests. [In chapter 2] you will be taken through what a unit test is, the basic syntax, and examples of a simple unit test. Then, you take a comprehensive look at the methods available to use in unit testing and [in chapter 3] the various tools [NOSE and PyTest] available to help in running and debugging your tests. Wrapping up the unit test section, you look into the pivotal use of mocks and patching, which allow you to isolate the code you are interested in testing (your “units”), and simulate responses from other parts of the system or libraries.

[Including executable test cases] in your documentation is one of the more interesting parts of Python testing. [Chapter 4] shows you how to effectively embed unit tests in your doc strings and have them run as tests […]

Your attention then turns to the more recent hot topic of test driven development (TDD)[…] The TDD section [chapter 5] introduces the concepts and ethos of the practice and covers steps required to adopt it. I provide [simple] use cases using TDD in pair programming […]

One of the more recent aspects of testing and something the development community as a whole has moved toward is the concept of behavior driven development (BDD) and acceptance testing [using Lettuce, a Python adjusted version of Cucumber, and briefly mentioning Robot -see chapters 6, 7]. This builds on the TDD approach, helping you to construct tests that ensure features of your application meet the acceptance criteria of your stakeholders […]

[Chapter 8 covers performance testing tools, Jmeter and cProfile].

[Chapter 9] also covers keeping your code in check. In the development cycle, you write a lot of code and in the majority of cases this code needs to be read by someone other than you. This means effective, actionable standards need to be applied across the Python community. This is where PEP-8 came in and tools have evolved around this to help maintain the standards. You look at effective ways to use tools such as PyLint and code coverage to ensure your code is maintainable, and your tests cover the parts of your application that matter.

A key feature of many teams is having some form of build [and deployment processes. Chapter 10 and 11 introduce Paver to automate build processes and Jenkins for continuous integration, showing how, together with Heroku, they can thread together the previous tools amd provide help for deployment on the Cloud]. After applying all these techniques and processes to your application, you should then be nearing release of your product! This is where you take a look into smoke testing (a type of testing which shows different components of an application are working together correctly)...
Although I agree with the Goodreads reviewer Arquero who considers that the chapters on deployment are not quite up to scratch, kudos to David Sale for providing an excellent and very down to earth overview of how an important number of software development tools for Python programs focused around testing fit together. Since this is such a dynamic area, I only hope a second edition is on the verge of coming out, focusing on up-to-date open-source tools for Python 3.
Profile Image for Hibiscus.
339 reviews
August 31, 2018
Makes some very clear and useful notes on testing proper.
With a whole lot of common wisdom and nice examples.

TDD with unit tests
BDD with acceptance tests
Smoke tests
Keeping mocks up-to-date

Blurred and so not much of avail when it comes to deployment.
No frowning though. The topic is quite advanced.
Profile Image for Snow.
330 reviews1 follower
September 18, 2015
This book is extremely easy to read and actually fun. It teaches you about the main concepts of testing in Python, unit testing (also, mocking and patching), nose, coverage reports, acceptance testing, pylint, continuous integration and lots of other things. If you don't know anything about unit testing this is great. However, just count this as an introduction and be prepared to read others books or check online for more in depth tutorials and library details. This book will introduce you to the steps that you need to take as a professional programmer to launch an application.
Profile Image for Pavel Karateev.
18 reviews5 followers
September 15, 2015
There is simply no other option - if you want to get familiar with Python testing practices you should definitely read it. And it's a pretty good book after all.

Pros:
- a lot of topics;
- code examples you may follow;
- simple style.

Cons:
- some covered tools can be dead already;
- no Python 3;
- code errors;
- topics aren't covered deeply;
- not for language newcomers.
Profile Image for Alex.
52 reviews10 followers
December 26, 2014
I was familiar with some of the material and was able to skim though some chapters. The book however has opened some new perspectives for me in regards to acceptance/performance testing (and the tools that can be used for that) as well as the automating the dev process. Very easy to read and helpful book which I shall be using as reference I am sure.
Great book.
Profile Image for Mik Vargas.
62 reviews
October 1, 2017
In general, it is a really good book. I hope the author publishes an updated version focused on Python 3. It is very informative, but some of the suggested frameworks are not available for Python 3.
Profile Image for Arsenii Yamnii.
12 reviews
July 3, 2020
Good for learn TDD. And good for Python QA. First half of book, its only unit tests. Second its QA.
Profile Image for Mihai.
186 reviews17 followers
November 17, 2021
A really good testing ABC which, even if old, still has a lot of good nuggets of information available.
Profile Image for Dgg32.
146 reviews6 followers
October 16, 2014
It is short walk through of the python test process. I learned the basic from it. Thank you the author!
230 reviews3 followers
November 10, 2015
It is a good book on testing in Python. I found the topics very well defined and explained. The structure of the chapters is also quite consistent.
Displaying 1 - 13 of 13 reviews

Can't find what you're looking for?

Get help and learn more about the design.