Skip to main content

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

  • Conference paper

Part of the Lecture Notes in Computer Science book series (LNPSE,volume 7019)

Abstract

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.

Keywords

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

References

  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)

    CrossRef  Google Scholar 

  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)

    CrossRef  Google Scholar 

  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)

    CrossRef  Google Scholar 

  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. Beizer, B.: Black-box testing: techniques for functional testing of software and systems. John Wiley & Sons, Inc., New York (1995)

    Google Scholar 

  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)

    CrossRef  Google Scholar 

  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)

    CrossRef  Google Scholar 

  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)

    CrossRef  Google Scholar 

  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)

    CrossRef  Google Scholar 

  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)

    CrossRef  Google Scholar 

  11. DeMillo, R.A., Offutt, A.J.: Constraint-Based Automatic Test Data Generation. IEEE Trans. Softw. Eng. 17(9), 900–910 (1991)

    CrossRef  Google Scholar 

  12. Enderlin, I.: Hoa Framework project (2010), http://hoa-project.net

  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)

    CrossRef  Google Scholar 

  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)

    CrossRef  Google Scholar 

  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. 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)

    CrossRef  Google Scholar 

  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)

    CrossRef  Google Scholar 

  18. Meyer, B.: Eiffel: programming for reusability and extendibility. SIGPLAN Not. 22(2), 85–94 (1987)

    CrossRef  Google Scholar 

  19. Meyer, B.: Applying ”design by contract”. Computer 25(10), 40–51 (1992)

    CrossRef  Google Scholar 

  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)

    CrossRef  Google Scholar 

  21. PHP Group. The PHP website (2010), http://www.php.net

  22. Tillmann, N., de Halleux, J.: Pex: White box test generation for.net. In: Beckert, B., Hähnle, R. (eds.) TAP 2008. LNCS, vol. 4966, pp. 134–153. Springer, Heidelberg (2008)

    CrossRef  Google Scholar 

  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)

    CrossRef  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and Permissions

Copyright information

© 2011 IFIP International Federation for Information Processing

About this paper

Cite this paper

Enderlin, I., Dadeau, F., Giorgetti, A., Ben Othman, A. (2011). Praspel: A Specification Language for Contract-Based Testing in PHP. In: Wolff, B., Zaïdi, F. (eds) Testing Software and Systems. ICTSS 2011. Lecture Notes in Computer Science, vol 7019. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-24580-0_6

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-24580-0_6

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-24579-4

  • Online ISBN: 978-3-642-24580-0

  • eBook Packages: Computer ScienceComputer Science (R0)