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

java – 为Spring启动应用程序编写Spock测试用例

发布时间:2020-12-15 01:48:36 所属栏目:大数据 来源:网络整理
导读:我正在开发spring boot应用程序.我必须为它编写测试用例.我以前没有写过测试用例,所以有人建议使用spock框架.我探索了spock,我认为它与groovy语言更相关. 我可以为我的春季应用程序编写spock测试用例吗? 如果是这样,那么你能否建议我更好地记录“如何在春季

我正在开发spring boot应用程序.我必须为它编写测试用例.我以前没有写过测试用例,所以有人建议使用spock框架.我探索了spock,我认为它与groovy语言更相关.

我可以为我的春季应用程序编写spock测试用例吗?

如果是这样,那么你能否建议我更好地记录“如何在春季启动应用程序中使用它”?

最佳答案
是的,你可以为你的spring应用程序编写spock测试用例.

查看official documentation,了解使用Spring Boot进行Spock测试的示例

35.3.1 Using Spock to test Spring Boot applications

一个简单的谷歌搜索揭示了Using Spock to test Spring classes的基本示例.

Spock relies heavily on the Spring’s TestContext framework and does
this via the @ContextConfiguration annotation. This allows the test
specification class to load an application context from one or more
locations.

Spring One g2x有一篇关于使用Spock测试Java,Groovy,Spring和Web应用程序的大型演示文稿.

Groovy和Java可以自由混合在一起,您可以使用任何您喜欢的基于Java的库,或使用基于Groovy的库.

The Spring framework supports Groovy and – not surprisingly – Spring
TestContext framework works well with Spock Spock specifications can
be run from an IDE just like normal JUnit tests and,last but not
least,implementing them is a great opportunity to learn the Groovy
language.source

(编辑:李大同)

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

    推荐文章
      热点阅读