Http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE 517 Fall 2010/ch1 S10 MS: Difference between revisions
(→Python) |
No edit summary |
||
Line 1: | Line 1: | ||
== Python == | == Python == | ||
Line 52: | Line 51: | ||
|} | |} | ||
== Ruby == | == Ruby == | ||
Line 148: | Line 110: | ||
| | | | ||
|} | |} | ||
== C# == | |||
The list of frameworks that apply for .NET are applied for C#. A long list of testing frameworks are available for C# which are csUnit, NUnit, dotunit, VSNUnit, Nester[8]. | |||
{| {{table}} | |||
| align="center" style="background:#f0f0f0;"|'''''' | |||
| align="center" style="background:#f0f0f0;"|'''NUnit''' | |||
| align="center" style="background:#f0f0f0;"|'''csUnit''' | |||
| align="center" style="background:#f0f0f0;"|'''Systin''' | |||
|- | |||
| Description||NUnit has been ported from JUnit and has been written completely to take the advantage of the .NET languages.||It is a free open source unit testing tool for all the test-driven development .NET languages including C#. ||Systin creates a domain specific testing language which allows an automatic testing of applications at the system level. | |||
|- | |||
| ||The major advancements with NUnit are parameterized tests which provides a concise method to express a set of examples that can used to run individual test cases.||It has been inspired from JUnit and can be used as an add-in along with the NUnit||The tests can be written in a simple document which can be converted to a .net language driver class | |||
|- | |||
| Examples||http://www.nunit.org/blogs/||http://www.csunit.org/tutorials/tutorial7/|| | |||
|- | |||
| |||||| | |||
|- | |||
| Used as||Testing framework, GUI and console tool||Testing Framework , Console tool and VS.NET Add In|| | |||
|- | |||
| | |||
|} | |||
== References == | |||
[1] http://www.c2.com/cgi/wiki?TestingFramework | |||
[2] http://en.wikipedia.org/wiki/Doctest | |||
[3] http://en.wikipedia.org/wiki/Unit_testing | |||
[4] http://www.elctech.com/tutorials/rspec-tutorial | |||
[5] http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html | |||
[6] http://www.ruby-forum.com/topic/144083 | |||
[7] http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog | |||
[8] http://csharp-source.net/open-source/testing-tools |
Revision as of 20:17, 21 September 2009
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
' | doctest | unittest |
Simplicity | Best suited for novice programmers | A little complex to use specially if unaware of Junit |
Documentation | Better Narratives | Tests have little or no comments |
Comprehensive testing | Doctests get clutterd for comprehensive tests and thus less readable | Best suited for comprehensive tests |
Flexibility and Control | Less flexible | More flexible |
Ruby
The basic testing framework for RUBY is xUnit . There are some frameworks which have evolved over the years which include RSpec, Trantula, Flog, RunCodeRun, Cucumber etc. We’ll talk about each of them in brief
Testing Framework | ' |
Rspec[4] | It is Behavior Driven Development whose basic features are |
· Behavior counts first, testing follows | |
· It focuses more on business values | |
· It’s more about getting the words right rather than just writing the test first | |
Advantages: | |
· These are extremely easy to read and makes sense to a non-programmer | |
· Rspec lets you unit test while also providing mocking and stubbing support | |
· Rspec can help with the coverage tests using Rcov | |
· One can also perform integration test using Rspec | |
Disadvantages: | |
· It involves a lot of behind the scene metaprogramming which makes the tests very difficult to understand | |
A simple Rspec example can be read at http://rspec.info/ | |
Cucumber[5] | Cucumber, the latest addition to the Rspec family allows one to execute documentation written in plain text(known as ‘stories’) |
A very good example of writing a test in cucumber can be read at http://cukes.info/ | |
Tarantula[6] | Tarantula is a Rail’s plugin that produces a detailed report describing the URL’s that it has crawled across and the responses that it received from each one of them. |
Tarantula\'s functionality somewhat overlaps with the on site testing, particularly if you are practicing test-driven development (TDD). Tarantula runs against your actual Web site thereby helping you to identify the problems associated with your production server, user-generated data, and HTML compliance. | |
Flog[7] | Flog is a tool which gives you a profile of your code’s complexity. It can given the complexity pertaining to each method in your code. One can also set threshold for each method using flog |
The complexity of a code can be important to | |
· Find the bugs as they are highly probable in complex code areas | |
· Complex codes can be considered for refactoring | |
A flog report has been explained and shown here http://www.ruby-forum.com/topic/131931 | |
C#
The list of frameworks that apply for .NET are applied for C#. A long list of testing frameworks are available for C# which are csUnit, NUnit, dotunit, VSNUnit, Nester[8].
' | NUnit | csUnit | Systin |
Description | NUnit has been ported from JUnit and has been written completely to take the advantage of the .NET languages. | It is a free open source unit testing tool for all the test-driven development .NET languages including C#. | Systin creates a domain specific testing language which allows an automatic testing of applications at the system level. |
The major advancements with NUnit are parameterized tests which provides a concise method to express a set of examples that can used to run individual test cases. | It has been inspired from JUnit and can be used as an add-in along with the NUnit | The tests can be written in a simple document which can be converted to a .net language driver class | |
Examples | http://www.nunit.org/blogs/ | http://www.csunit.org/tutorials/tutorial7/ | |
Used as | Testing framework, GUI and console tool | Testing Framework , Console tool and VS.NET Add In | |
References
[1] http://www.c2.com/cgi/wiki?TestingFramework [2] http://en.wikipedia.org/wiki/Doctest [3] http://en.wikipedia.org/wiki/Unit_testing [4] http://www.elctech.com/tutorials/rspec-tutorial [5] http://www.rubyinside.com/cucumber-the-latest-in-ruby-testing-1342.html [6] http://www.ruby-forum.com/topic/144083 [7] http://www.brynary.com/2007/9/13/scourging-your-ruby-code-with-flog [8] http://csharp-source.net/open-source/testing-tools