Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Python Testing Cookbook, Second Edition
Title Page
Copyright and Credits
Python Testing Cookbook Second Edition
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the authors
About the reviewers
Packt is searching for authors like you
Table of Contents
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Sections
Getting ready
How to do it…
How it works…
There's more…
See also
Get in touch
Reviews
Using Unittest to Develop Basic Tests
Introduction
Asserting the basics
Getting ready
How to do it...
How it works...
There's more...
assertEquals is preferred over assertTrue and assertFalse
self.fail([msg]) can usually be rewritten with assertions
Our version of Python can impact our options
Setting up and tearing down a test harness
How to do it...
How it works...
Running test cases from the command line
How to do it...
How it works...
There's more...
Running a subset of test case methods
How to do it...
How it works...
Chaining together a suite of tests
How to do it...
How it works...
There's more...
The name of the test case should be significant
Defining test suites inside the test module
How to do it...
How it works...
There's more...
Test suite methods must be outside of the test class
Why have different suites?
optparse is being phased out and replaced by argparse
Retooling old test code to run inside unittest
How to do it...
How it works...
There's more...
Where are the bugs?
FunctionTestCase is a temporary measure
Breaking down obscure tests into simple ones
How to do it...
How it works...
There's more...
Where is the bug?
What is the right size for a test method?
Unittests versus integration tests
Testing the edges
How to do it...
How it works...
There's more...
Identifying the edges is important
Testing for unexpected conditions
Testing corner cases by iteration
How to do it...
How it works...
There's more...
Does this defy the recipe – breaking down obscure tests into simple ones?
How does this compare with the recipe – testing the edges?
See also
Running Automated Test Suites with Nose
Introduction
Getting nosy with testing
How to do it...
How it works...
There's more...
Nose is extensible
Nose is embeddable
See also
Embedding nose inside Python
How to do it...
How it works...
There's more...
Writing a nose extension to pick tests based on regular expressions
Getting ready
How to do it...
How it works...
There's more...
Writing a nose extension to generate a CSV report
Getting ready
How to do it...
How it works...
There's more...
Writing a project-level script that lets you run different test suites
How to do it...
How it works...
There's more...
Why use getopt instead of optparse?
Creating Testable Documentation with doctest
Introduction
Documenting the basics
How to do it...
How it works...
There's more...
Catching stack traces
How to do it...
How it works...
Running a doctest from the command line
How to do it...
How it works...
Coding a test harness for doctest
How to do it...
How it works...
There's more...
Filtering out test noise
How to do it...
How it works...
There's more...
Printing out all your documentation including a status report
How to do it...
How it works...
There's more...
Testing the edges
How to do it...
How it works...
There's more...
See also
Testing corner cases by iteration
How to do it...
How it works...
Does this type of test fit better into doctest or unittest?
See also
Getting nosy with doctest
Getting ready
How to do it...
How it works...
Updating the project-level script to run this chapter's doctests
How to do it...
How it works...
There's more...
Testing Customer Stories with Behavior-Driven Development
Introduction
Naming tests that sound like sentences and stories
Getting ready
How to do it...
How it works...
There's more...
Testing separate doctest documents
Getting ready 
How to do it...
How it works...
There's more...
Doesn't this defy the usability of docstrings?
Writing a testable story with doctest
Getting ready
How to do it...
How it works...
There's more...
Writing a testable novel with doctest
Getting ready
How to do it...
How it works...
There's more...
Writing a testable story with Voidspace Mock and nose
Getting ready
How to do it...
How it works...
There's more...
Tell me more about the spec nose plugin!
Why didn't we reuse the plugin from the recipe "Naming tests so they sound like sentences and stories"?
See also
Writing a testable story with mockito and nose
Getting ready
How to do it...
How it works...
See also
Writing a testable story with Lettuce
Getting ready...
How to do it...
How it works...
There's more...
How complex should a story be?
Don't mix wiring code with application code
Lettuce works great using folders
See also
Using Should DSL to write succinct assertions with Lettuce
Getting ready
How to do it...
How it works...
There's more...
See also
Updating the project-level script to run this chapter's BDD tests
Getting ready
How to do it...
How it works...
See also
High-Level Customer Scenarios with Acceptance Testing
Introduction
Installing Pyccuracy
How to do it...
How it works...
See also
Testing the basics with Pyccuracy
Getting ready
How to do it...
How it works...
There's more...
See also
Using Pyccuracy to verify web app security
Getting ready
How to do it...
How it works...
See also
Installing Robot Framework
How to do it...
There's more...
Creating a data-driven test suite with Robot Framework
Getting ready
How to do it...
How it works...
There's more...
Do I have to write HTML tables?
What are the best ways to write the code that implements our custom keywords?
Robot Framework variables are Unicode
See also
Writing a testable story with Robot Framework
Getting ready
How to do it...
How it works...
There's more...
Given-When-Then results in duplicate rules
Do the try-except blocks violate the idea of keeping things light?
See also
Tagging Robot Framework tests and running a subset
Getting ready
How to do it...
How it works...
There's more...
What about documentation?
See also
Testing web basics with Robot Framework
Getting ready...
How to do it...
How it works...
There's more...
Learn about timing configurations – they may be important!
See also
Using Robot Framework to verify web app security
Getting ready
How to do it...
How it works...
There's more...
Why not use a "remember me" option?
Shouldn't we refactor the first test scenario to use the keyword?
Would arguments make the login keyword more flexible?
See also
Creating a project-level script to verify this chapter's acceptance tests
Getting ready
How to do it...
How it works...
There's more
Can we only use getopt?
What's wrong with using the various command-line tools?
Integrating Automated Tests with Continuous Integration
Introduction
Generating a CI report for Jenkins using NoseXUnit
Getting ready
How to do it...
How it works...
Configuring Jenkins to run Python tests upon commit
Getting ready
How to do it...
How it works...
There's more...
Do I have to use git for source code management?
What is the format of polling?
See also
Configuring Jenkins to run Python tests when scheduled
Getting ready
How to do it...
How it works...
There's more...
Jenkins versus TeamCity
See also
Generating a CI report for TeamCity using teamcity-nose
Getting ready
How to do it...
How it works...
Configuring TeamCity to run Python tests upon commit
Getting ready
How to do it...
How it works...
There's more...
What did teamcity-nose give us?
See also
Configuring TeamCity to run Python tests when scheduled
Getting ready
How to do it...
How it works...
See also
Measuring Your Success with Test Coverage
Introduction
Building a network management application
How to do it...
How it works...
Installing and running coverage on your test suite
How to do it...
There's more...
Why are there no asserts in unittest?
Generating an HTML report using coverage
How to do it...
How it works...
Generating an XML report using coverage
How to do it...
How it works...
What use is an XML report?
See also
Getting nosy with coverage
How to do it...
How it works...
There's more...
Why use the nose plugin instead of the coverage tool directly?
Why are SQLite3 and Spring Python included?
Filtering out test noise from coverage
How to do it...
How it works...
There's more...
See also
Letting Jenkins get nosy with coverage
Getting ready
How to do it...
How it works...
There's more...
Nose doesn't directly support coverage's XML option
Updating the project-level script to provide coverage reports
Getting ready
How to do it...
How it works...
There's more...
Can we only use getopt?
Smoke/Load Testing – Testing Major Parts
Introduction
Defining a subset of test cases using import statements
How to do it...
How it works...
There's more...
Security, checking, and integration aren't smoke tests!
What provides good flexibility?
See also
Leaving out integration tests
How to do it...
How it works...
There's more...
Should a smoke test include integration or unit tests?
See also
Targeting end-to-end scenarios
Getting ready
How to do it...
How it works...
There's more...
How does this define smoke tests?
See also
Targeting the test server
Getting ready
How to do it...
How it works...
There's more...
How likely is it that a development and production environment would use two different database systems?
This isn't just confined to database systems
Coding a data simulator
Getting ready
How to do it...
How it works...
There's more...
Why does the server script initialize the database?
Why MySQL instead of SQLite?
See also
Recording and playing back live data in real time
Getting ready
How to do it...
How it works...
There's more...
I thought this recipe was about live data!
Is opening and closing a file for every event a good idea?
What about offloading the storage of data?
See also
Recording and playing back live data as fast as possible
Getting ready
How to do it...
How it works...
There's more...
What is the difference between this and playing back in real time?
Where are the breaking points of this application?
What amount of live data should be collected?
See also
Automating your management demo
How to do it...
How it works...
There's more...
What if my manager likes to take detours?
Good Test Habits for New and Legacy Systems
Introduction
Something is better than nothing
How to do it...
How it works...
That can't be everything!
See also
Coverage isn't everything
How to do it...
How it works...
There's more...
Are we not supposed to increase coverage?
But I want to brag about the coverage of my system!
Be willing to invest in test fixtures
How to do it....
How it works...
There's more...
Is this just about setting up a database?
If you aren't convinced about the value of testing, your team won't be either
Harvesting metrics
How to do it...
How it works...
There's more...
Metrics aren't just for defending yourself to management
Capturing a bug in an automated test
How to do it...
How it works...
There's more...
When the time comes to add a completely new module, you will be ready for it
Don't give into the temptation to skip testing
Separating algorithms from concurrency
How to do it...
How it works...
Research test options provided by your concurrency frameworks
Pause to refactor when a test suite takes too long to run
How to do it...
How it works...
There's more...
See also
Cash in on your confidence
How to do it...
How it works...
Be willing to throw away an entire day's changes
How to do it...
How it works...
There's more...
How does this mesh with "Something is better than nothing"
See also
Instead of shooting for 100 percent coverage, try to have a steady growth
How to do it...
How it works...
Randomly breaking up your app can lead to better code
How to do it...
How it works...
There's more...
How does this compare to fuzz testing?
Are there any tools to help with this?
Other Books You May Enjoy
Leave a review - let other readers know what you think
← Prev
Back
Next →
← Prev
Back
Next →