摘要:
执行多个测试套件(suites)Chaining together a suite of testsUnittest makes it easy to chain together test cases into a TestSuite. A TestSuite can be runjust like a TestCase, but it also provides additional functionality to add a single test, multipletests, and count them.1. Create a new file named recipe5.py 阅读全文
摘要:
根据不同的命令行参数进行不同代码的单元测试。Running a subset of test case methodsSometimes it's convenient to run only a subset of test methods in a given test case. This recipewill show how to run either the whole test case, or pick a subset from the command line.1. Create a new file named recipe4.py in which to put 阅读全文
摘要:
Running test cases from the command line with increased verbosity.It is easy to adjust the test runner to print out every test method as it is run.1. Create a new file called recipe3.py in which to store this recipe's code.2. Pick a class to test. In this case, we will use our Roman numeral conv 阅读全文
摘要:
Setting up and tearing down a test harness.With the following steps, we will setup and teardown a test harness for each test method.1. Create a new file called recipe2.py in which to put all our code for this recipe.2. Pick a class to test. In this case, we will use a slightly altered version of our 阅读全文
摘要:
一个非常简单的python的测试用例,取自电子书:《Python Testing Cookbook》第一章内容,里面说的足够简单明了,将之摘出来,对照代码,应该很容易理解。 The basic concept of an automated unittest test case is to instantiate part of our code, subject it to operations... 阅读全文