加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – DUnit:’Global’SetUp和TearDown

发布时间:2020-12-15 04:17:43 所属栏目:大数据 来源:网络整理
导读:在DUnit中,在执行每个测试方法之前(以及之后)调用SetUp和TearDown. 在SetUp中,我创建了一个从文件加载数据的对象.这很慢,特别是如果我有很多测试. 在执行所有测试之前有没有办法调用SetUp一次(对于TearDown来说显然是相同的)? 解决方法 从 documentation:
在DUnit中,在执行每个测试方法之前(以及之后)调用SetUp和TearDown.
在SetUp中,我创建了一个从文件加载数据的对象.这很慢,特别是如果我有很多测试.
在执行所有测试之前有没有办法调用SetUp一次(对于TearDown来说显然是相同的)?

解决方法

从 documentation:

TTestSetup

TTestSetup can be used when you wish to set up state exactly once for
a test case class (the SetUp and TearDown methods are called once for
each test method). For example,if you were writing a suite of tests
to exercise some database code,you might subclass TTestSetup and use
it to open and close the database before executing the suite.

An an example how to use TTestSetup

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读