SenTestCase 中的测试夹具设置方法相当于什么?
与大多数单元测试框架一样,SenTestCase 具有setUp 和tearDown 方法,您可以重写它们以在每次测试之前和之后运行代码。
在 NUnit 中,我习惯于拥有一个可以重写的夹具设置和夹具拆卸方法,这将让我在运行任何测试之前运行一次代码,并在运行夹具中的所有测试后清理一次。
使用 SenTestCase 执行此操作的正确方法是什么?我尝试使用 init 和 dealloc 来实现此目的,但与我更好的判断相反,但似乎我的 init 重写从未被调用。
Like most unit testing frameworks, SenTestCase has setUp and tearDown methods you can override to run code before and after each test.
In NUnit, I'm used to having a fixure setup and fixture teardown method I can override, too, that will let me run code once before any test is run, and clean up once after all tests in the fixture are run.
What's the proper way to do this with SenTestCase? I tried using init and dealloc for this, against my better jugment, but it seemed like my init override was never called.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
+setUp
和+tearDown
类方法:SenTestKit:在所有测试运行后进行清理?。You can use the
+setUp
and+tearDown
class methods: SenTestKit: cleaning up after ALL tests have run?.我已经切换到 GHUnit,它有这个功能。据我所知 OCUnit/SenTestCase 没有。
I've switched to GHUnit, which has this feature. As far as I can tell OCUnit/SenTestCase does not.