How it works...

A unit test can be developed independently by the developer, but it is good practice to have a standard product such as unittest and adhere to a common test practice. 

As you can see from the following example, the test method was set by using the eq_ function. This is similar to assertEquals by unittest, which verifies that the two parameters are equal:

    def test_mult(self):
eq_(2*2,4)

def ignored(self):
eq_(2*2,3)

This testing practice, despite good in intentions, has obvious limitations, such as not being able to be repeated over time (for example, when a software module changes) for so-called regression tests.

Here is the output:

C:>nosetests -v testset.py
testset.TestSuite.test_mult ... ok

-----------------------------------------------------------
Ran 1 tests in 0.001s

OK

In general, testing is not able to identify all the errors in a program and the same is true for unit testing, which, by analyzing individual units by definition, cannot identify integration errors, performance problems, and other system-related problems. In general, unit testing is more effective when used in conjunction with other software testing techniques.

Like any form of testing, even unit testing cannot certify the absence of errors, but can only highlight their presence.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset