等价类测试与边界值测试

发布于 2024-08-15 07:55:31 字数 45 浏览 4 评论 0原文

我了解等效性测试的工作原理。

它与边界值测试有何相同或不同?

I understand how equivalence testing works.

How is it the same or different from boundary value testing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

咋地 2024-08-22 07:55:31

等价类测试
EC 测试是指您想要测试多个测试项目(例如值),但由于成本(时间/金钱)而没有时间测试所有项目。因此,您将测试项目分组到类中,其中每个类中的所有项目都假定行为完全相同。理论上,您只需测试每一项中的一项即可确保系统正常工作。
示例 1
2 岁以下儿童免费乘坐巴士。年轻人支付 10 美元,成人支付 15 美元,老年人支付 5 美元。
课程:
价格:0->年龄:0-1
价格:10->年龄:2-14
价格:15->年龄:15-64
价格:5->年龄:65-无穷大

示例 2(多个参数)
手机 K80、J64 和 J54 运行 Java 5。K90 和 J99 运行 Java 6。但有两种可能的浏览器 FireFox 和 Opera,J 型号运行 FF,K 型号运行 O。
课程:
浏览器:FF,Java:5 ->手机:J64、J54
浏览器:FF,Java:6 ->手机:J99
浏览器:O,Java:5 ->手机:K80
浏览器:O,Java:6 ->手机:K90

等效类测试的危险
使用 EC 测试存在一种危险,这种危险在测试书籍中很少提及,但记住这一点非常重要。
仅仅因为两个项目/值应该属于同一类并且行为相同,并不意味着它们的行为相同。
这意味着仅仅因为您测试类中的一个值,类中的所有值都会表现相同。我的现实世界的例子是所有手机都具有特定的 Java 平台。他们本应以相同的方式工作,但实际上并非如此。因此,仅测试类中的一个值固然很好,但还不够好。 EC 测试是一个很好的工具,但它并不是万无一失的,所以要小心使用。如果测试用例便宜且快速(例如自动化),请进行更多测试,或者为什么不测试全部!

边界值测试
BV 测试是指您决定测试已确定的每个类别的边缘值。理论上来说,大多数缺陷都存在于类的边缘。
示例
课程:
价格:0->年龄:0-1(边界值0、1)
价格:10->年龄:2-14(边界值2、14)
价格:15->年龄:15-64(界限值15、64)
价格:5->年龄:65-无穷大(边界值 65)

边界值测试批判
1) 我和我接受过课程的其他测试专业人​​员并不相信大多数缺陷都隐藏在每个课程的边缘。我从未见过任何研究证明这一点。
2) 您需要使用 BV 测试这一事实证明 EC 测试是有缺陷的,因为您测试每个类别的多个值。
3)使用整数等值时很容易使用。但是手机型号类别或浏览器版本的边界值是多少?

隐藏边界值测试
类的边界值通常基于系统应如何工作的规范。这一切都很好,但大多数系统都包含任何规范中未解释的边界,您需要自己寻找。例如,“在系统出现故障和崩溃之前,我可以在测试字段中放入多少个字符。”,“在读取速度如此缓慢而令人烦恼之前,数据文件可以变成多大”。
现实世界的例子
- 在 Win 7 上的 FireFox 3.5 中将一百万个字符粘贴到文本区域会导致崩溃
- ReCaptcha 的字符数限制为 16003 个字符,如果有人在字段中输入超过 16004 个字符,您的系统是否会处理返回给它的 413 个字符。还是它坏了

总结
EC 测试和 BV 测试是很棒的工具,您应该使用它们,但它们并不完美,并且不要指望使用它们找到所有缺陷。利用您对系统的了解以及您的智力和直觉来尝试更多项目并寻找其他可能失败的方式。并寻找隐藏的边界!

Equivalence Class Testing
EC Testing is when you have a number of test items (e.g. values) that you want to test but because of cost (time/money) you do not have time to test them all. Therefore you group the test item into class where all items in each class are suppose to behave exactly the same. The theory is that you only need to test one of each item to make sure the system works.
Example 1
Children under 2 ride the bus for free. Young people pay $10, Adults $15 and Senior Citizen pay $5.
Classes:
Price:0 -> Age:0-1
Price:10 -> Age:2-14
Price:15 -> Age:15-64
Price:5 -> Age:65-infinity

Example 2 (more than one parameter)
Cellphones K80, J64 and J54 run Java 5. K90 and J99 run Java 6. But there are two possible browsers FireFox and Opera, J models run FF and K models run O.
Classes:
Browser:FF, Java:5 -> Phones:J64,J54
Browser:FF, Java:6 -> Phones:J99
Browser:O, Java:5 -> Phones:K80
Browser:O, Java:6 -> Phones:K90

Dangers Of Equivalence Class Testing
There is a danger of using EC Testing that is rarely mentioned in the testing books but is very important to remember.
Just because two items/values are suppose to be in the same class and behave the same, does not mean they DO behave the same.
That means that just because you test one value in the class that ALL values in the class behave the same. Real world example of mine is with cell phones that all had a certain Java Platform. They were suppose to all work the same but they didn't in reality. So testing just one value in a class is good, but not good enough. EC Testing is a good tool, but it's not fool proof and be careful with it. If test cases are cheap and fast (like automation), test more, or why not test them all!

Boundary Value Testing
BV Testing is when you decide to test the values on the edge of each Class you have identified. The theory is that most defects is around the edges of a class.
Example
Classes:
Price:0 -> Age:0-1 ( Boundary values 0, 1)
Price:10 -> Age:2-14 ( Boundary values 2, 14)
Price:15 -> Age:15-64 ( Boundary values 15, 64)
Price:5 -> Age:65-infinity ( Boundary values 65)

Critique of Boundary Value Testing
1) I, and other test professionals I have taken courses from, are not convinced that most defects are hidden around the edges of each class. And I have never seen any studies that proves this to be the case.
2) The fact that you need to use BV Testing proves that EC Testing is flawed since you test more than one value of each class.
3) It's easy to use when using values like integers. But what is a boundary value of class of phones models or browsers versions?

Hidden Boundary Value Testing
The boundary values of a class is often based on the specification of how the system should work. This is all good and well but most systems contain boundaries that are not explained in any spec and you will need to look for yourself. E.g. 'How many characters can I put into the test field before the system fails and breaks.','How big can the data file become before it so slow to read it gets annoying'.
Real world examples
- Pasting one million characters into a text area in FireFox 3.5 on win 7 crashes it
- ReCaptcha has a limit of 16003 characters, does your system handle the 413 that it passes back to it if somebody puts 16004+ characters in field. Or does it break

Summary
EC Testing and BV Testing are great tools and you should use them but they are not perfect and don't expect to find all defects using them. Use your know-how about the system and your intelligence and intuition to try more items and looks for other ways it could fail. And look for the hidden boundaries!

国际总奸 2024-08-22 07:55:31

边界值分析简单地说就是选择类边界附近的值。因此,您仍然根据类来划分输入域,而不是从类的中间选择值,使用边界中的值。

例如,如果输入条件的范围为 20 到 70,则您有三类输入

  1. 小于 20
  2. 介于 20 和 70 之间
  3. 大于 70

那么对于边界值分析,选择输入 = 19, 20, 21, 69, 70, 71这种类型的分析会发现边界上的错误。

Boundary value analysis simply means to select values near the boundaries of the classes. So you are still dividing the input domain according to the classes then instead of selecting values from the middle of the class use values from the boundaries.

For example, if the input condition is a range from 20 to 70 then you have three classes of input

  1. less than 20
  2. between 20 and 70
  3. more than 70

then for boundary value analysis select input = 19, 20, 21, 69, 70, 71. This type of analysis picks up errors on the boundaries.

金橙橙 2024-08-22 07:55:31

等价测试需要补充边界值测试。

例如,对取值在 1 到 12 之间的函数进行等效测试
(比如一年中的几个月)分区将是:

  • 值小于 1 (0,-1,-2),无效分区
  • 值在 1-12 之间,有效分区
  • 值大于 12,无效分区
  • 对于等价测试,从每个分区类中选择一个值作为测试输入就足够了。这意味着值为 -2,6 和 15 的测试将被认为足以测试函数的行为。但这些值无法捕获 Off-by-one 错误,这种错误可能会发生经常。

    通过边界值测试,测试输入将为:-1,0,1,11,12,13(在边界处),这将捕获小一错误。

    我认为这两种测试方法是相辅相成的。

    The Equivalence testing needs to be supplemented with the Boundary value testing.

    For example for equivalent testing of a function that takes values between 1 and 12
    (say months of a year) the partitions would be:

  • values less than 1 (0,-1,-2), invalid partition
  • values between 1-12, valid partition
  • values greater than 12,invalid partition
  • For equivalence testing it is enough to pick one value as test input from each of these partition classes. That would mean tests with value of -2,6, and 15 would be considered enough to test behavior of the function. But these values doesn't catch Off-by-one error which can occur quite often.

    With the boundary value testing the test inputs would be : -1,0,1,11,12,13 (at the boundaries), which would catch off-by-one errors.

    I see both these testing methods to be a complement of each other.

    留蓝 2024-08-22 07:55:31

    边界值分析是等价划分的一部分或子集。在边界值分析中,仅选择边界内的值,而不是某些随机值。

    Boundary value analysis is part or subset of equivalence partitioning. In boundary values analysis, instead of some random value, only values in the boundary are selected.

    感性不性感 2024-08-22 07:55:31

    边界值分析克服了等价类划分的缺点。如果固定长度是 g9iven 例如。手机号码(10 位数字。)

    本例中的下限为 - 数字 - 1(即 10 - 1 =9)
    本例中的上限是-数字+1(即10 + 1 = 11)

    现在我们可以对9和11进行测试

    Boundary value analysis overcome the drawback of the Equivalance class partitioning. If a fix length is g9iven for eg. Mobile number (10 digit.)

    The lower boundary in this case is - digit - 1 (ie. 10 - 1 =9)
    The upper boundary in this case is - digit +1 (ie 10 + 1 =11)

    Now we can perform test for the 9 and 11

    黒涩兲箜 2024-08-22 07:55:31

    动态测试类型 -

    1. 基于规范的测试

      A.等价划分

      <前><代码> A1。边界值分析

      A2。决策表

      A3。用例测试

      A4。状态转换测试

    2. 基于结构的测试

      A.测试覆盖率

      B.代码覆盖率

      C.报表覆盖范围

      D.决策覆盖率

    3. 基于经验的测试

      A.错误测试

      B.探索性测试

    等价划分 - 这是一种测试人员将测试条件分为组和集的技术。系统应该同等地处理它们,因此称为等价类。测试每个分区的一个条件将假设所有条件都适用于该分区。

    前>>检查个位数的加法。即 0 到 9 之间的值。

    1. 值小于 -9,即 -10、-11,...。 (无效分区)

    2. 值小于 0,即 -1、-2、...。直到 -9(有效分区)

    3. 0-9 之间的值,即 0,1 …。直到 9(有效分区)

    4. 值大于 9,即 10,11(无效分区)

    测试每个分区的任意两个值的相加为足够的。

    边界值测试 – 它基于分区之间边界的测试。

    前>>考虑下面的组合。

    1. -9 和 -10 相加,

    2. -10 和 -11 相加

    3. 相加

      0 相加和-1

    4. 0和1相加

    5. 9和10相加

    6. 11 和 10 相加

    Dynamic Testing Types –

    1. Specification Based testing

      A. Equivalance Partitioning

        A1. Boundary value analysis
      
        A2. Decision Tables
      
        A3. Use case Testing
      
        A4. State Transition testing
      
    2. Structural Based testing

      A. Test Coverage

      B. Code coverage

      C. Statement coverage

      D. Decision coverage

    3. Experience Based Testing

      A. Error testing

      B. Exploratory Testing

    Equivalance Partitioning – It is a technique where tester divide the test conditions into groups and sets. System should handle them equivalently hence called equivalence classes. To test one condition from each partition will work to assume all condition will work in that partition.

    EX >> Check addition of the single digit values. i.e. values between 0 and 9.

    1. Values less than -9, i.e. -10,-11, …. (Invalid partition)

    2. Values less than 0, i.e. -1,-2, …. till -9 (Valid Partition)

    3. Values between 0-9 i.e. 0,1 …. till 9 (Valid Partition)

    4. Values greater than 9, i.e. 10,11 (Invalid partition)

    Testing the addition for any two values of each partition is enough.

    Boundary value testing – It is based on testing at the boundaries between partition.

    EX >> Consider below combination.

    1. Addition of -9 and -10,

    2. Addition of -10 and -11

    3. Addition of 0 and -1

    4. Addition of 0 and 1

    5. Addition of 9 and 10

    6. Addition of 11 and 10

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文