Difference between revisions of "Unit Testing"

m
 

(One intermediate revision by the same user not shown)



Line 39: Line 39:
  
 
As the last line in the output shows that one test(test_double) failed out of the two tests.
 
As the last line in the output shows that one test(test_double) failed out of the two tests.
 +
----
 +
http://en.wikipedia.org/wiki/Unit_testing

Latest revision as of 06:06, 15 August 2007

Unit Testing means testing small chunks of code. We want to be sure that when we write any software we are really DoneDone. TestDrivenDevelopment says that you should write your tests before writing any code as the tests gives you insights into what exactly you want to do. Then incrementally you keep on passing the test cases and when you have passed all the test cases, you are then confident that the code works

Following is a small example of unit testing in Ruby. We have made a new class named MyClass and have written a small unit test named TestMyClass to test this class

require 'test/unit'
class MyClass
  def square(val)
    return val*val
  end
  def double(val)
    return val
  end
end
class TestMyClass  expected but was
. 
2 tests, 2 assertions, 1 failures, 0 errors

As the last line in the output shows that one test(test_double) failed out of the two tests.


http://en.wikipedia.org/wiki/Unit_testing



Retrieved from "http://aboutus.com/index.php?title=Unit_Testing&oldid=8893536"