From: "Thomas B." Date: 2008-08-30T22:26:02+09:00 Subject: Re: using assert outside of test unit Adam Akhtar wrote: > hi is it possible to use assert in your actual code i.e. not just in the > unit test but in say your class methods etc. > > I tried to use it but ruby complains its not a recognised method for my > class. (i made sure to write require 'test/unit' at the top of my class > file.) > > Unit testing is great for checking what methods return but Id also like > to check whats going on inside sometimes. Having the program stop and > tell me when something i didnt expect will also help to prevent bugs. > > Is it possible. I googled and checked previous posts here but couldnt > find anything. Those asserts are instance methods of Test::Unit::TestCase so you cannot use them outside the testcases. But you could probably dynamically define your own class (or maybe there is one already) that holds an instance of Test::Unit::TestCase and redirects all assertions to it. -- Posted via http://www.ruby-forum.com/.