Praspel: A Specification Language for Contract-Based Testing in PHP

  • Ivan Enderlin
  • Frédéric Dadeau
  • Alain Giorgetti
  • Abdallah Ben Othman
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7019)


We introduce in this paper a new specification language named Praspel, for PHP Realistic Annotation and SPEcification Language. This language is based on the Design-by-Contract paradigm. Praspel clauses annotate methods of a PHP class in order to both specify their contracts, using pre- and postconditions, and assign realistic domains to the method parameters. A realistic domains describes a set of concrete, and hopefully relevant, values that can be assigned to the data of a program (class attributes and method parameters). Praspel is implemented into a unit test generator for PHP that offers a random test data generator, which computes test data, coupled with a runtime assertion checker, which decides whether a test passes or fails by checking the satisfaction of the contracts at run-time.


PHP Design-by-Contract annotation language unit testing formal specifications 


  1. 1.
    Aichernig, B.K.: Contract-based testing. In: Aichernig, B.K. (ed.) Formal Methods at the Crossroads. From Panacea to Foundational Support. LNCS, vol. 2757, pp. 34–48. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  2. 2.
    Artzi, S., Kiezun, A., Dolby, J., Tip, F., Dig, D., Paradkar, A., Ernst, M.D.: Finding bugs in dynamic web applications. In: Proceedings of the 2008 International Symposium on Software Testing and Analysis, ISSTA 2008, pp. 261–272. ACM, New York (2008)CrossRefGoogle Scholar
  3. 3.
    Barnett, M., Leino, K.R.M., Schulte, W.: The Spec# Programming System: An Overview. In: Barthe, G., Burdy, L., Huisman, M., Lanet, J.-L., Muntean, T. (eds.) CASSIS 2004. LNCS, vol. 3362, pp. 49–69. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  4. 4.
    Baudin, P., Filliâtre, J.-C., Hubert, T., Marché, C., Monate, B., Moy, Y., Prevosto, V.: ACSL: ANSI C Specification Language (preliminary design V1.2) (2008)Google Scholar
  5. 5.
    Beizer, B.: Black-box testing: techniques for functional testing of software and systems. John Wiley & Sons, Inc., New York (1995)Google Scholar
  6. 6.
    Bouquet, F., Dadeau, F., Legeard, B.: Automated Boundary Test Generation from JML Specifications. In: Misra, J., Nipkow, T., Karakostas, G. (eds.) FM 2006. LNCS, vol. 4085, pp. 428–443. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  7. 7.
    Boyapati, C., Khurshid, S., Marinov, D.: Korat: Automated Testing based on Java Predicates. In: ISSTA 2002: Proceedings of the 2002 ACM SIGSOFT International Symposium on Software Testing and Analysis, pp. 123–133. ACM, New York (2002)CrossRefGoogle Scholar
  8. 8.
    Campbell, C., Grieskamp, W., Nachmanson, L., Schulte, W., Tillmann, N., Veanes, M.: Testing concurrent object-oriented systems with spec explorer. In: Fitzgerald, J.S., Hayes, I.J., Tarlecki, A. (eds.) FM 2005. LNCS, vol. 3582, pp. 542–547. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  9. 9.
    Cheon, Y., Leavens, G.T.: A simple and practical approach to unit testing: The JML and JUnit way. In: Deng, T. (ed.) ECOOP 2002. LNCS, vol. 2374, pp. 231–255. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  10. 10.
    Ciupa, I., Leitner, A., Oriol, M., Meyer, B.: ARTOO: Adaptive Random Testing for Object-Oriented Software. In: ICSE 2008: Proceedings of the 30th International Conference on Software Engineering, pp. 71–80. ACM, New York (2008)CrossRefGoogle Scholar
  11. 11.
    DeMillo, R.A., Offutt, A.J.: Constraint-Based Automatic Test Data Generation. IEEE Trans. Softw. Eng. 17(9), 900–910 (1991)CrossRefGoogle Scholar
  12. 12.
    Enderlin, I.: Hoa Framework project (2010),
  13. 13.
    Gligoric, M., Gvero, T., Jagannath, V., Khurshid, S., Kuncak, V., Marinov, D.: Test generation through programming in UDITA. In: ICSE 2010: Proceedings of the 32nd ACM/IEEE International Conference on Software Engineering, pp. 225–234. ACM, New York (2010)CrossRefGoogle Scholar
  14. 14.
    Heidegger, P., Thiemann, P.: Contract-Driven Testing of JavaScript Code. In: Vitek, J. (ed.) TOOLS 2010. LNCS, vol. 6141, pp. 154–172. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  15. 15.
    Leavens, G.T., Baker, A.L., Ruby, C.: JML: A notation for detailed design. In: Kilov, H., Rumpe, B., Simmonds, I. (eds.) Behavioral Specifications of Businesses and Systems, pp. 175–188. Kluwer Academic Publishers, Boston (1999)Google Scholar
  16. 16.
    Leavens, G.T., Cheon, Y., Clifton, C., Ruby, C., Cok, D.R.: How the design of JML accommodates both runtime assertion checking and formal verification. In: de Boer, F.S., Bonsangue, M.M., Graf, S., de Roever, W.-P. (eds.) FMCO 2002. LNCS, vol. 2852, pp. 262–284. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  17. 17.
    Madsen, P.: Unit Testing using Design by Contract and Equivalence Partitions. In: Marchesi, M., Succi, G. (eds.) XP 2003. LNCS, vol. 2675, pp. 425–426. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  18. 18.
    Meyer, B.: Eiffel: programming for reusability and extendibility. SIGPLAN Not. 22(2), 85–94 (1987)CrossRefGoogle Scholar
  19. 19.
    Meyer, B.: Applying ”design by contract”. Computer 25(10), 40–51 (1992)CrossRefGoogle Scholar
  20. 20.
    Oriat, C.: Jartege: A Tool for Random Generation of Unit Tests for Java Classes. In: Reussner, R., Mayer, J., Stafford, J.A., Overhage, S., Becker, S., Schroeder, P.J. (eds.) QoSA 2005 and SOQUA 2005. LNCS, vol. 3712, pp. 242–256. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  21. 21.
    PHP Group. The PHP website (2010),
  22. 22.
    Tillmann, N., de Halleux, J.: Pex: White box test generation In: Beckert, B., Hähnle, R. (eds.) TAP 2008. LNCS, vol. 4966, pp. 134–153. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  23. 23.
    Visser, W., Pǎsǎreanu, C.S., Khurshid, S.: Test input generation with Java PathFinder. SIGSOFT Softw. Eng. Notes 29(4), 97–107 (2004)CrossRefGoogle Scholar

Copyright information

© IFIP International Federation for Information Processing 2011

Authors and Affiliations

  • Ivan Enderlin
    • 1
  • Frédéric Dadeau
    • 1
  • Alain Giorgetti
    • 1
  • Abdallah Ben Othman
    • 1
  1. 1.LIFC / INRIA CASSIS ProjectBesançon cedexFrance

Personalised recommendations