Skip to main content
  • Book
  • © 2022

Python Unit Test Automation

Automate, Organize, and Execute Unit Tests in Python

Apress

Authors:

  • Covers all the important libraries such as doctest, pydoc, unittest, nose2, and pytest
  • The test modules are explained with practical applications
  • Covers text-driven development with Python and Selenium

Buy it now

Buying options

Softcover Book USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Other ways to access

Table of contents (8 chapters)

  1. Front Matter

    Pages i-xxi
  2. Introduction to Python

    • Ashwin Pajankar
    Pages 1-23
  3. Getting Started

    • Ashwin Pajankar
    Pages 25-41
  4. unittest

    • Ashwin Pajankar
    Pages 43-90
  5. nose and nose2

    • Ashwin Pajankar
    Pages 91-121
  6. pytest

    • Ashwin Pajankar
    Pages 123-141
  7. Testing with Selenium

    • Ashwin Pajankar
    Pages 143-159
  8. Logging in Python

    • Ashwin Pajankar
    Pages 161-191
  9. Tips and Tricks

    • Ashwin Pajankar
    Pages 193-204
  10. Back Matter

    Pages 205-209

About this book

Learn how to automate unit tests of Python 3 with automation libraries, such as doctest, unittest, nose, nose2, pytest, and selenium. This book explores important concepts in software test automation and demonstrates how to automate, organize, and execute unit tests with Python. It also introduces readers to the concepts of web browser automation and logging.

This new edition starts with an introduction to Python 3. Next, it covers doctest and pydoc. This is followed by a discussion on unittest, a framework that comes packaged with Python 3 itself. There is a dedicated section on creating test suites, followed by an explanation of how nose2 provides automatic test module discovery. Moving forward, you will learn about pytest, the most popular third-party library and testrunner for Python. You will see how to write and execute tests with pytest. You’ll also learn to discover tests automatically with pytest.

This edition features two brand new chapters, the firstof which focuses on the basics of web browser automation with Selenium. You’ll learn how to use Selenium with unittest to write test cases for browser automation and use the Selenium IDE with web browsers such as Chrome and Firefox. You’ll then explore logging frameworks such as Python’s built-in logger and the third-party framework loguru.

The book concludes with an exploration of test-driven development with pytest, during which you will execute a small project using TDD methodology.

What You Will Learn

  • Start testing with doctest and unittest
  • Understand the idea of unit testing
  • Get started with nose 2 and pytest
  • Learn how to use logger and loguru
  • Work with Selenium and test driven development


Who This Book Is For
Python developers, software testers, open source enthusiasts, and contributors to the Python community.


Authors and Affiliations

  • Nashik, India

    Ashwin Pajankar

About the author

Ashwin Pajankar holds a Master of Technology from IIIT Hyderabad, and has over 25 years of programming experience. He started his journey in programming and electronics with BASIC programming language and is now proficient in Assembly programming, C, C++, Java, Shell Scripting, and Python. Other technical experience includes single board computers such as Raspberry Pi and Banana Pro, and Arduino. He is currently a freelance online instructor teaching programming bootcamps to more than 60,000 students from tech companies and colleges. His Youtube channel has an audience of 10000 subscribers and he has published more than 15 books on programming and electronics with many international publications.

Bibliographic Information

Buy it now

Buying options

Softcover Book USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Other ways to access