Http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE 517 Fall 2010/ch1 S10 MS

From Expertiza_Wiki
Revision as of 19:58, 21 September 2009 by Abhatt (talk | contribs)
Jump to navigation Jump to search

Python


Doctest: It is a simple, ingenuine technology that allows you to write a narrative in a document which can directly be executed as a test. It is included in Python as a module. Although doctest makes testing code readable for non-programmers ,the simplicity of a narrative test like doctest is accompanied by it’s own flaws .Some of the disadvantages of using doctest are

• These tests are difficult to handle in case of failures as they are more generic. Specific tests are narrower and better in communicating intent and ensuring coverage. • The test code is executed in a special way thus making it difficult to reason about how it will be executed. It is also harder to program around the tests. • It is actually difficult to get an outline of the tests at glance. There’s no tool that can give an overview of the unit tests in a doc test file [2] An detailed information about doctest with thorough examples can be read at http://docs.python.org/library/doctest.html


Unittest: Unittest are more specific tests which are more functional in nature allowing it to be written for individual functions or the class as a whole. The fact that Unittest is based on jUnit makes people with the xUnit familiarity pick it up really quick hence it is more Java based than python .It has been introduced in the Python’s library since version 2.1 The disadvantages of using the unit test are • The tests have a different look and feel with respect to the code under test • The assertions used in the text use custom syntax which makes it difficult • The test code is difficult to understand compared to the Doctest and the strong basis on jUnit makes it difficult for the pure Python coders [3] A detailed information about doctest with thorough examples can be read at http://docs.python.org/library/unittest.html



Doctest vs Unittest

Here we compare simple features of both the tests thus giving us an idea of which one to use based on the requirement