On 11 Aug 2000, Dave Thomas wrote:

> Hugh Sasse Staff Elec Eng <hgs / dmu.ac.uk> writes:
> 
> > Has anyone written any English docs on getting started with RubyUnit?
> > I expaect there will be lots of information in Dave and Andy's book, 
> > but in the meantime I cannot find much to give me the basic concepts
> > on how to use this.  I had a search with Google for information but
> > didn't see much.
> 
> Sorry - we don't have a chapter on it (umm... maybe we should have)
> but it's pretty straightforward.
> 
> A basic recipe is:
> 
	[...]
OK
> 
> Within each test, use the 'assert' methods to perform a test:
> 
>    assert(boolean, [ optional message])
>    assert_equal(expected, actual [, msg])
	[..]
>    assert_no_exception(*arg) {block}
> 
That is a useful set to have.
> 
> Then, you can also write two instance methods to setup the environment 
> for each test, and to tear it down afterwards (setup and teardown
> respectively).
> 
> 
> As an example, here's some of the code we use to test class Array:
> 
> 
> class TestArray < Rubicon::TestCase
> 
>   def test_00_new
>     a = Array.new()
>     assert_instance_of(Array, a)
>     assert_equal(0, a.length)
>     assert_nil(a[0])
>   end
	[...]
> end
> 
Yes that is clear, and it explains how to test for sensible results in
many cases.  I was thinking that test cases might have to be more
mathematical than that, but that sort of thing is pretty exhaustive, if
suitable examples are chosen.
> 
> (We actually inherit from our own class, Rubicon, which does more
> statistics collection than the basic runit. Rubicon--if the code
> crosses it, we get to take over the world)

:-)  and I thought Rubicon would be a goal directed module for string
processing without using regular expressions... :-)

> 
> Hope this helps.
> 
Yes, it does.
> 
> Dave
> 
> 
	Thank you,
	Hugh