什么是生成单元测试框架? [英] What is a Generative Unit Test Framework?

查看:104
本文介绍了什么是生成单元测试框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在stackoverflow上,我遇到了mbunit.在其页面上,它指出mbunit是一个生成单元测试框架,但是我找不到任何地方可以描述什么是生成单元测试框架.

On stackoverflow I've come across mbunit. On its page it states that mbunit is a generative unit test framework, but I can't find anywhere that describes what a Generative unit test framework is.

我希望得到:

  • 定义
  • 链接到有关什么是生殖单元测试框架和不是生殖单元测试框架的文章.

推荐答案

生成测试框架是代码本身生成测试案例的框架.

A generative testing framework is one where the code itself generates test cases.

通常,您根据要测试的一个或多个假设编写代码以生成测试用例.

Typically you write code to generate test cases according to one or more assumptions you would like to test.

我对mbunit本身并不陌生,但是例如使用Clojure生成测试框架 test.generative 您可以编写如下测试:

I'm not fambiliar with mbunit itself, but for example using the Clojure generative test framework test.generative you can write tests like:

(defspec integers-closed-over-addition
  (fn [a b] (+' a b))                    ;; input fn
  [^long a ^long b]                      ;; input spec
  (assert (integer? %)))                 ;; 0 or more validator forms

此测试直接指定您要测试的假设(即,两个long的总和总是一个整数).

This test directly specifies the assumption you want to test (i.e. that the addition of two longs always results in an integer).

重要的一点是,您不必指定特定的long值进行测试-框架本身将生成输入的任意组合,并检查您的断言在每种情况下是否成立.

The important point is that you don't have to specify particular long vales for testing - the framework itself will generate arbitrary combinations of inputs and check that your assertions hold true in every case.

这篇关于什么是生成单元测试框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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