Skip to content

Commit

Permalink
Merge pull request #386 from input-output-hk/ch1bo/mutation-test-speed
Browse files Browse the repository at this point in the history
Lower requirement for coverage percent in genericCoverTable
  • Loading branch information
ch1bo committed Jun 3, 2022
2 parents 0e3fbe5 + 1c0cbed commit 9acd79d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions hydra-test-utils/src/Test/Hydra/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,17 @@ genericCoverTable xs =
coverTable tableName requirements . tabulate tableName (show <$> xs)
where
tableName = show $ typeRep (Proxy :: Proxy a)
requirements =
[ (show lbl, weight)
| let weight = fromRational (100 % (3 * lengthI allLabels))
, lbl <- allLabels
]
requirements = [(show lbl, percent) | lbl <- allLabels]
-- NOTE: We lower the requirement of minimum coverage depending on the number
-- of labels, e.g. 3 labels would have an ideal, uniform distribution of 33%
-- each, but we only require 33% / 3 = 11%. With 10 labels evenly distributed
-- means 10%, but getting 10% / 3 = 3% would be much harder to achieve with
-- this bigger set to draw from. Hence we only expect 10% / 10 = 1% coverage
-- in that case and consequently should reasonable numbers of tests required.
percent = fromRational (100 % (numberOfLabels * numberOfLabels))
allLabels = enumerate :: [a]
enumerate = [minBound .. maxBound]
lengthI = toInteger . length
numberOfLabels = toInteger $ length allLabels

-- | Shorthand for using 2 generated values in a property.
forAll2 ::
Expand Down

0 comments on commit 9acd79d

Please sign in to comment.