Groovy测试API [英] Groovy for testing an API

查看:182
本文介绍了Groovy测试API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有几个很好的测试脚本,用Groovy编写,它提供了这种测试并建立了我们需要的信心,并且我们正在考虑将它们整合到夜间构建中,并允许QA团队运行它们。这是单元测试的一个步骤,因为我们正在寻找完整的端到端工作流程,而不是原子步骤。



输出目前是人类可读的,每个测试条件打印出一条定义测试的线,正在读取的值以及一个真/假来显示测试条件是否通过。



我想包装这成为一个更高层次的脚本,它可以单独调用每个脚本,然后分析输出。我自己可以很轻松地做到这一点,但想知道是否已经有Groovy Test框架,所以我不重新发明轮子。

解决方案

JUnit,TestNG和 Spock 对于Groovy编写测试(不仅仅是单元)来说都是合理的选择。选择其中一个并使用您选择的构建系统运行测试。诸如 Gradle 之类的构建系统可以引导自身,这将使QA的生活更轻松(无需安装)。



免责声明:我是Spock创始人和Gradle提交者。


I'm writing a series of automated, end-to-end test cases that exercise a RestFUL API.

I have several good test scripts, written in Groovy, that provide the sort of tests and build the confidence we need, and we're looking at integrating these into a nightly build, as well as allow the QA team to run them. This is a step above Unit testing, as we are looking at complete end-to-end workflows, rather than atomic steps.

The output is currently human readable, with each test condition printing out a line which defines the test, the value being read, and a true/false to show if the test condition passes.

I'd like to wrap this into a higher level script that calls each script individually and then analyzes the outputs. I can do this easily enough myself, but was wondering if there's a Groovy Test framework out there already so I don't re-invent the wheel.

解决方案

JUnit, TestNG, and Spock are all reasonable choices for writing (not just unit) tests in Groovy. Pick one of them and run the tests with your build system of choice. A build system like Gradle that can bootstrap itself will make life easier for QA (no installation required).

Disclaimer: I'm Spock founder and Gradle committer.

这篇关于Groovy测试API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆