doctest and unittest

The one of the important aspects of software development is testing of the software. The testing is done to check whether the developed software works in all desired situations properly. unittest is preparation of test conditions before the development of code for each and every functions we are intending to do. In case of doctest test conditions are embedded along with the docstring of each methods.

In doctest testing along with the docstring ,test condition and the corresponding result are given. This provide the users to look into the working of the section with an example. We can make the test running by calling a method testmod() which is present in the module doctest.

If the code written by us is correct it will return the result as ok, otherwise returns failiure.

unittest allow to maintain the test module in a new file and can run it any time we need to test explicitly.The test conditions in unittest are actually made before the coding of the original code. It is the first step of coding. It makes the problem very clear thus making us to work for that specific goal. It will control us from deviating from the goal.

On calling the unittest.main(), the main() method of unittest is invoked. This will make the test running and the output formating is done. If a failure occur number of failed test and trackback to the most recent call is shown.
The problem with unittest is the module will only test the method which starts the name ‘test’.

About Odol Shinu

I've completed my B Tech in Information Technology in 2010 from Government Engineering College Sreekrishnapuram Palakkad under Calicut University.

Posted on September 18, 2010, in Python. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: