SenTestCase 中的测试夹具设置方法相当于什么?

发布于 2024-11-26 23:43:23 字数 254 浏览 3 评论 0原文

与大多数单元测试框架一样,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朱染 2024-12-03 23:43:23

您可以使用 +setUp+tearDown 类方法:SenTestKit:在所有测试运行后进行清理?

You can use the +setUp and +tearDown class methods: SenTestKit: cleaning up after ALL tests have run?.

離殇 2024-12-03 23:43:23

我已经切换到 GHUnit,它有这个功能。据我所知 OCUnit/SenTestCase 没有。

I've switched to GHUnit, which has this feature. As far as I can tell OCUnit/SenTestCase does not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文