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

前端之家收集整理的这篇文章主要介绍了java – 为Spring启动应用程序编写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

原文链接:https://www.f2er.com/spring/432703.html

猜你在找的Spring相关文章