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

单元测试 – 我应该在Grails应用程序中将Groovy类的测试用例放在

发布时间:2020-12-14 16:24:30 所属栏目:大数据 来源:网络整理
导读:我的应用程序中有几个Groovy类,在src / groovy下.关联的测试类应该去哪里,他们应该使用GroovyTestCase还是mixins(TestFor)? 解决方法 您可以为班级选择单元测试或集成测试.从 docs你可以看到它们之间的区别: 单元测试 Unit testing are tests at the “uni
我的应用程序中有几个Groovy类,在src / groovy下.关联的测试类应该去哪里,他们应该使用GroovyTestCase还是mixins(TestFor)?

解决方法

您可以为班级选择单元测试或集成测试.从 docs你可以看到它们之间的区别:

单元测试

Unit testing are tests at the “unit” level. In other words you are
testing individual methods or blocks of code without consideration for
surrounding infrastructure. Unit tests are typically run without the
presence of physical resources that involve I/O such databases,socket
connections or files. This is to ensure they run as quick as possible
since quick feedback is important.

集成测试

Integration tests differ from unit tests in that you have full access
to the Grails environment within the test.

因此,如果您需要访问数据库或需要完整的环境,请执行集成测试.如果没有,创建一个单元测试(这将使用内存数据库).

@TestFor旨在用于单元测试,因为这将模拟基本测试(参见GrailsUnitTestMixin).如果选择集成测试,请不要使用注释.

(编辑:李大同)

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

    推荐文章
      热点阅读