Hello I have a trouble with Ruby unit testing, I'm new to it so some help would be lovely
class TestItem < Test::Unit::TestCase def setUp @item=Item.new('Food','Burger',120) end def testGetType assert_equal(@item.getType,'Food') end end
Here the value of instance variable @item takes nil when I declare it in setUp() and use it in test functions! So I get an error like no method 'getType' for nil-class
But when I directly use it like assert_equal(Item.new('Food','Burger',120).getType,'Food'),it works fine.
Please point out to my mistakes, thanks in advance