Python Testing Cookbook
Book information
Description
This cookbook is written as a collection of code recipes containing step-by-step directions on how to install or build different types of Python test tools to solve different problems. Each recipe contains explanations of how it works along with answers to common questions and cross references to other relevant recipes. The easy-to-understand recipe names make this a handy test reference book. Python developers and programmers with a basic understanding of Python and Python testing will find this cookbook beneficial. It will build on that basic knowledge equipping you with the intermediate and advanced skills required to fully utilize the Python testing tools. Broken up into lots of small code recipes, you can read this book at your own pace, whatever your experience. No prior experience of automated testing is required. Cover Copyright Credits About the Author About the Reviewers www.PacktPub.com Table of Contents Preface Chapter 1: Using Unittest To Develop Basic Tests Introduction Asserting the basics Setting up and tearing down a test harness Running test cases from the command line with increased verbosity Running a subset of test case methods Chaining together a suite of tests Defining test suites inside the test module Retooling old test code to run inside unittest Breaking down obscure tests into simple ones Testing the edges Testing corner cases by iteration Chapter 2: Running Automated Test Suites with Nose Introduction Getting nosy with testing Embedding nose inside Python Writing a nose extension to pick tests based on regular expressions Writing a nose extension to generate a CSV report Writing a project-level script that lets you run different test suites Chapter 3: Creating Testable Documentation with doctest Introduction Documenting the basics Catching stack traces Running doctests from the command line Coding a test harness for doctest Filtering out test noise Printing out all your documentation including a status report Testing the edges Testing corner cases by iteration Getting nosy with doctest Updating the project-level script to run this chapter's doctests Chapter 4: Testing Customer Stories with Behavior Driven Development Introduction Naming tests that sound like sentences and stories Testing separate doctest documents Writing a testable story with doctest Writing a testable novel with doctest Writing a testable story with Voidspace Mock and nose Writing a testable story with mockito and nose Writing a testable story with Lettuce Using Should DSL to write succinct assertions with Lettuce Updating the project-level script to run this chapter's BDD tests Chapter 5: High Level Customer Scenarios with Acceptance Testing Introduction Installing Pyccuracy Testing the basics with Pyccuracy Using Pyccuracy to verify web app security Installing the Robot Framework Creating a data-driven test suite with Robot Writing a testable story with Robot Tagging Robot tests and running a subset Testing web basics with Robot Using Robot to verify web app security Creating a project-level script to verify this chapter's acceptance tests Chapter 6: Integrating Automated Tests with Continuous Integration Introduction Generating a continuous integration report for Jenkins using NoseXUnit Configuring Jenkins to run Python tests upon commit Configuring Jenkins to run Python tests when scheduled Generating a CI report for TeamCity using teamcity-nose Configuring TeamCity to run Python tests upon commit Configuring TeamCity to run Python tests when scheduled Chapter 7: Measuring your Success with Test Coverage Introduction Building a network management application Installing and running coverage on your test suite Generating an HTML report using coverage Generating an XML report using coverage Getting nosy with coverage Filtering out test noise from coverage Letting Jenkins get nosy with coverage Updating the project-level script to provide coverage reports Chapter 8: Smoke/Load Testing—Testing Major Parts Introduction Defining a subset of test cases using import statements Leaving out integration tests Targeting end-to-end scenarios Targeting the test server Coding a data simulator Recording and playing back live data in real time Recording and playing back live data as fast as possible Automating your management demo Chapter 9: Good Test Habits for New and Legacy Systems Introduction Something is better than nothing Coverage isn't everything Be willing to invest in test fixtures If you aren't convinced on the value of testing, your team won't be either Harvesting metrics Capturing a bug in an automated test Separating algorithms from concurrency Pause to refactor when test suite takes too long to run Cash in on your confidence Be willing to throw away an entire day of changes Instead of shooting for 100 percent coverage, try to have a steady growth Randomly breaking your app can lead to better code Index
Similar books
Spring Python 1.1: Create powerful and versatile Spring Python applications using pragmatic libraries and useful abstractions
2010 · PDF
MySQL® Notes for Professionals book
2018 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
Session C11: Ancient Cultural Landscapes in South Europe – their Ecological Setting and Evolution, Session C22: Gardeners from South America, Session S04: Agro-Pastoralism and Early Metallurgy Sessions, Session WS29: The Idea of Enclosure in Recent Iberian Prehistory, Session C88: Rhytmes et causalites des dynamiques de l'anthropisation en Europe entre 6500 ET 500 BC: Hypotheses socio-culturelles et/ou climatiques: Proceedings of the XV UISPP World Congress (Lisbon 4-9 September 2006) / Actes du XV Congrès Mondial (Lisbonne 4-9 Septembre 2006) Vol.36
2010 · PDF
THE BRITISH ARMY IN INDIA: ITS PRESERVATION BY AN APPROPRIATE CLOTHING, HOUSING, LOCATING, RECREATIVE EMPLOYMENT, AND HOPEFUL ENCOURAGEMENT OF THE TROOPS. with AN APPENDIX ON INDIA : THE CLIMATE OP ITS HILLS ; THE DEVELOPMENT OF ITS RESODRCBS, INDUSTRY, AND ARTS ; THE ADMINISTRATION OF JUSTICE ; THE BLACK ACT ; THE PROGRESS OF CHRISTIANITY ; THE TRAFFIC IN OPIUM ; THE VALUE OF INDIA ; PERMANENT CAUSES OF DISAFFECTION, AND OF THE RECENT REBELLION ; THE TRADITIONARY POLICY; MISGOVERNMENT BY NATIVE RULERS ; ANNEXATIONS OF THEIR TERRITORY, ETC.
1858 · PDF
Idries Shah 27 Books Collection : A Perfumed Scorpion, A Veiled Gazelle, Caravan of Dreams, Darkest England, Destination Mecca, Evenings with Idries Shah, Knowing How to Know, Learning How to Learn, Letters and Lectures of Idries Shah, Neglected aspects of Sufi study, Observations, Oriental Magic, Reflections, Seeker after Truth, Special Illumination, Special Problems in the study of Sufi ideas, Sufi thought and action, Tales of the Dervishes, The Dermis Probe, The Elephant in the Dark, The Englishman Handbook, Idries Shah Antology, The Magic Monastery, The natives are restless, wisdom of the Idiots PDF.
2022 · PDF
The travels of Capts. Lewis and Clarke from St. Louis, by way of the Missouri and Columbia rivers, to the Pacific ocean; performed in the years 1804, 1805 & 1806, by order of the government of the United States. Containing delineations of the manners, customs, religion, &c. of the Indians, comp. from various authentic sources, and original documents, and a summary of the Statistical view of the Indian nations, from the official communication of Meriwether Lewis. Illustrated with a map of the country, inhabited by the western tribes of Indians
1809 · PDF