public class TodoListTest extends TestCase { (中略) public void testTodoList() throws Exception { assertEquals("洗車する", ((Todo) todoList.get(0)).getTitle()); assertEquals(0, ((Todo) todoList.get(0)).getProgress()); } }
class TodosControllerTest < Test::Unit::TestCase fixtures :todos def setup @controller = TodosController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end def test_add post :add, :todo => {:title => '書籍を購入する', :progress => 0} assert_equal "success", flash[:notice] assert_redirected_to :action => 'list' assert_equal 3, Todo.find_all.size end end