How to use combinations of sets as test data

前端 未结 5 1343
陌清茗
陌清茗 2020-12-05 13:45

I would like to test a function with a tuple from a set of fringe cases and normal values. For example, while testing a function which returns true whenever giv

5条回答
  •  春和景丽
    2020-12-05 14:39

    While it's possible to create lots of test data and see what happens, it's more efficient to try to minimize the data being used.

    From a typical QA perspective, you would want to identify different classifications of inputs. Produce a set of input values for each classification and determine the appropriate outputs.

    Here's a sample of classes of input values

    • valid triangles with small numbers such as (1 billion, 2, billion, 2 billion)
    • valid triangles with large numbers such as (0.000001, 0.00002, 0.00003)
    • valid obtuse triangles that are 'almost'flat such as (10, 10, 19.9999)
    • valid acute triangles that are 'almost' flat such as (10, 10, 0000001)
    • invalid triangles with at least one negative value
    • invalid triangles where the sum of two sides equals the third
    • invalid triangles where the sum of two sides is greater than the third
    • input values that are non-numeric

    ...

    Once you are satisfied with the list of input classifications for this function, then you can create the actual test data. Likely, it would be helpful to test all permutations of each item. (e.g. (2,3,4), (2,4,3), (3,2,4), (3,4,2), (4,2,3), (4,3,2)) Typically, you'll find there are some classifications you missed (such as the concept of inf as an input parameter).

    Random data for some period of time may be helpful as well, that can find strange bugs in the code, but is generally not productive.

    More likely, this function is being used in some specific context where additional rules are applied.(e.g. only integer values or values must be in 0.01 increments, etc.) These add to the list of classifications of input parameters.

提交回复
热议问题