문제

I recently noticed my test database is not being cleaned up after my tests run if my tests subclass Test::Unit::TestCase. If my tests subclass ActiveSupport::TestCase, everything is cleaned up properly.

Can anyone explain why, and/or provide an explanation of using one versus the other?

I am using shoulda and factory_girl.

Thanks.

도움이 되었습니까?

해결책

If you take a look at the code, you'll see ActiveSupport::TestCase has a lot of of setup and utility functions for testing Rails. Older versions of Rails used to use Test::Unit::TestCase with a lot of mixins, but moved to subclassing a while ago.

If you're testing a Rails app, you should subclass ActiveSupport::TestCase or ActionController:TestCase for controllers. The generators will do this automatically, so you should not have to think about it most of the time.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top