如何测试或描述无限的可能性? [英] how to test or describe endless possibilities?

查看:75
本文介绍了如何测试或描述无限的可能性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用伪代码的示例类:

class SumCalculator
  method calculate(int1, int2) returns int

什么是测试此问题的好方法?换句话说,我该如何描述自己需要的行为?

What is a good way to test this? In other words how should I describe the behavior I need?

test1: canDetermineSumOfTwoIntegers

test2: returnsSumOfTwoIntegers

test3: knowsFivePlusThreeIsEight

Test1和Test2似乎含糊不清,因此需要测试特定的计算,因此它并未真正描述所测试的内容.但是test3非常有限.

Test1 and Test2 seem vague and it would need to test a specific calculation, so it doesn't really describe what is being tested. Yet test3 is very limited.

什么是测试此类的好方法?

What is a good way to test such classes?

推荐答案

我将测试边界条件(max-int,min-int,零,正,负)和一些典型情况:

I would test the boundary conditions (max-int, min-int, zero, positive, negative) and some typical cases:

test1: sumOfPosAndPos
test2: sumOfPosAndNeg
test3: sumOfPosAndZero
test4: sumOfNegAndZero
test5: sumOfMaxIntAndMinInt

这篇关于如何测试或描述无限的可能性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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