CSC/ECE 517 Fall 2011/ch2 2e gp: Difference between revisions
Line 12: | Line 12: | ||
== Test::Unit == | == Test::Unit == | ||
The in-built, ready to use unit testing mechanism for Ruby is called Test::Unit.It belongs to the XUnit family unit testing framework. It has a setup method for initialization, a teardown method for cleanup and the actual test methods itself. The tests are bundled separately in a test class in the code it is aimed to test. | The in-built, ready to use unit testing mechanism for Ruby is called Test::Unit.It belongs to the XUnit family unit testing framework. It has a setup method for initialization, a teardown method for cleanup and the actual test methods itself. The tests are bundled separately in a test class in the code it is aimed to test. | ||
=== Assertions === | |||
{| border=1 cellspacing=0 cellpadding=5 | |||
| assert( boolean, [message] ) | |||
| True if ''boolean'' | |||
|- | |||
| assert_equal( expected, actual, [message] )<br>assert_not_equal( expected, actual, [message] ) | |||
| True if ''expected == actual'' | |||
|- | |||
| assert_raise( Exception,... ) {block}<br>assert_nothing_raised( Exception,...) {block} | |||
| True if the block raises (or doesn't) one of the listed exceptions. | |||
|- | |||
|} | |||
== Shoulda == | == Shoulda == |
Revision as of 15:19, 17 September 2011
Testing Frameworks for Ruby
This page serves as a knowledge source for understanding the different Testing Frameworks available for Ruby.
Introduction
There are a lot of testing tools that are available for Ruby language, they have different features and can be applied on different platforms. Here is a brief introduction and feature comparisons of popular testing frameworks. [EDIT NEEDED]
Unit Testing
Unit Testing is a method by which we can isolate and test a unit functionality of the program, typically individual methods during and long after the code is written.
Test::Unit
The in-built, ready to use unit testing mechanism for Ruby is called Test::Unit.It belongs to the XUnit family unit testing framework. It has a setup method for initialization, a teardown method for cleanup and the actual test methods itself. The tests are bundled separately in a test class in the code it is aimed to test.
Assertions
assert( boolean, [message] ) | True if boolean |
assert_equal( expected, actual, [message] ) assert_not_equal( expected, actual, [message] ) |
True if expected == actual |
assert_raise( Exception,... ) {block} assert_nothing_raised( Exception,...) {block} |
True if the block raises (or doesn't) one of the listed exceptions. |