skip to main content
research-article

QuickCheck: a lightweight tool for random testing of Haskell programs

Published:20 May 2011Publication History
Skip Abstract Section

Abstract

QuickCheck is a tool which aids the Haskell programmer in formulating and testing properties of programs. Properties are discribed as Haskell functions, and can be automatically tested on random input, but it is also possible to define custom test data generators. We present a number of case studies, in which the tool was successfully used, and also point out some pitfalls to avoid. Random testing is especially suitable for functional programs because properties can be stated at a fine grain. When a function is built from separately tested components, then random testing suffuces to obtain good coverage of the definition under test.

References

  1. S. Antoy and R. Hamlet. Automatically checking an implementation against its formal specification. In Irvine Software Symposium, pages 29--48, March 1992.Google ScholarGoogle Scholar
  2. Roland Backhouse, Patrik Jansson, Johan Jeuring, and Lambert Meertens. Generic Programming - An Introduction. In Lecture notes in Computer Science, volume 1608, 1999.Google ScholarGoogle Scholar
  3. P. Bjesse, K. Claessen, M. Sheeran, and S. Singh. Lava: Hardware Design in Haskell. In International Conference on Functional Programming, Baltimore, 1998. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. M. Blum and S. Kannan. Designing programs that check their work. In Proc. 21st Symposium on the Theory of Computing, pages 86--97. ACM, May 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. M. Blum, M. Luby, and R. Rubinfeld. Self-testing/correcting with applications to numerical problems. In Proc. 22nd Symposium on the Theory of Computing, pages 73--83. ACM, May 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. A. Celentano, S. C. Reghizzi, P. Della Vigna, and C. Ghezzi. Compiler testing using a sentence generator. Software - Practice & Experience, 10:897--918, 1980.Google ScholarGoogle Scholar
  7. K. Claessen and D. Sands. Observable Sharing for Functional Circuit Description. In Asian Computer Science Conference, Phuket, Thailand, 1999. ACM Sigplan. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. M. Davis and H. Putnam. A computing procedure for quantification theory. Journal of the Association for Computing Machinery, 7(3) :201--215, 1960. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. J. Duran and S. Ntafos. An evaluation of random testing. Transactions on Software Engineering, 10(4):438--444, July 1984.Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. J. Gannon, R. Hamlet, and P. McMullin. Data abstraction implementation, specification, and testing. Trans. Prog. Lang. and Systems, (3):211--223, 1981. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. D. Hamlet. Random testing. In J. Marciniak, editor, Encyclopedia of Software Engineering, pages 970--978. Wiley, 1994.Google ScholarGoogle Scholar
  12. R. Hamlet and R. Taylor. Partition testing does not inspire confidence. Transactions on Software Engineering, 16(12):1402--1411, December 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. J . Hughes. Why Functional Programming Matters. In D. Turner, editor, Research Topics in Functional Programming. Addison Wesley, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. M. P. Jones. The Hugs distribution. Currently available from http://haskell. org/hugs, 1999.Google ScholarGoogle Scholar
  15. P. M. Maurer. Generating test data with enhanced context-free grammars. IEEE Software, 7(4) :50--56, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Gunnar StaImarck. A System for Determining Propositional Logic Theorems by Applying Values and Rules to Triplets that are Generated from a Formula, 1989. Swedish Patent No. 467076 (approved 1992), U.S. Patent No.5 276 897 (1994), European Patent No. 0403 454 (1995).Google ScholarGoogle Scholar
  17. Philip Wadler. Theorems for free! In International Conference on Functional Programming and Computer Architecture, London, September 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Philip Wadler. A prettier printer, March 1998. Draft paper.Google ScholarGoogle Scholar

Index Terms

  1. QuickCheck: a lightweight tool for random testing of Haskell programs

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 46, Issue 4
        April 2011
        56 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1988042
        Issue’s Table of Contents

        Copyright © 2011 Authors

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 20 May 2011

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader