Hack book of
Unfortunately, the documentation of this library has not
been written yet. However, the
README.md file may contain
enough information to help you. This document is an extract of the
Sorry for this inconvenience. Be ensured we are working hard to fix this.
Praspel and the Realistic Domains
Praspel (PHP Realistic Annotation and Specification Language) is a formal specification language for PHP. It is based on the Design-by-Contract paradigm and uses preconditions, postconditions, invariants etc. Specifications are written in the comments of the PHP code. Praspel is used for manual, automated or automatic software validation and verification.
This language is inspired by JML but the
difference is in the way to specify the data. PHP is dynamically and
weakly typed. To specify the data, Praspel relies on realistic
domains: Structures allowing to validate and generate data, with the
ability to compose them to represent more complex data. Realistic
domains are implemented in
A contract can be used to automatically generate unit tests. A test is constitued of 2 parts: Test data, and an oracle. Test data are crucial since it must reflect “realistic” data as much as possible, and being to generate data at the limits is also very important. Realistic Domains is an answer to this problem by being able to generate integers, reals, strings (based on regular expressions or grammars for instance), arrays (based on a constraint solver) or objects, for the PHP language types. Thus, it is possible to combine these realistic domains to generate more sophisticated data (like dates, object models etc.).
Contract Coverage Criteria
The contract language can be evaluated to validate and verify data manipulated by the program on one hand. On the other hand, we have algorithms able to automatically generate test data from a piece of a contract. In order to ensure whether the contract is correctly covered, we have defined several contract coverage criteria.
Thus, we are able to generate unit test suites satisfying these contract coverage criteria, and thus ensuring that generated unit test suites reflect all the behavior expressed in the contract.
This language is the result of several research papers, journals and PhD thesis.
- Praspel: A Specification Language for Contract-Driven Testing in PHP, presented at ICTSS 2011 (Paris, France) (article, presentation),
- Grammar-Based Testing using Realistic Domains in PHP, presented at A-MOST 2012 (Montréal, Canada) (article, presentation, details),
- A Constraint Solver for PHP Arrays, presented at CSTVA 2013 (Luxembourg, Luxembourg) (article, presentation, details).
$ composer require hoa/praspel '~1.0'
For more installation procedures, please read the Source page.
Before running the test suites, the development dependencies must be installed:
$ composer install
Then, to run all the test suites:
$ vendor/bin/hoa test:run
For more information, please read the contributor guide.
An error or a suggestion about the documentation? Contributions are welcome!