-
Notifications
You must be signed in to change notification settings - Fork 1
Implementation of Constraint Handler
Huayao edited this page Jul 30, 2019
·
1 revision
In order to implement a new constraint handler in CCAG, you need to create a class that implements the ConstraintHandler
interface.
public interface ConstraintHandler {
// the set of supported constraint handlers
enum Handlers {
Verify, Solver, Replace, Tolerate
}
/**
* The process executed before test suite generation.
* @param model the test model of CT
*/
void pre(CTModel model);
/**
* The process executed after test suite generation.
* @param model the test model of CT
* @param ts the generated test suite
*/
void post(CTModel model, TestSuite ts);
/**
* Determine whether a given complete or partial test case is constraints
* satisfying. Any unfixed parameter should be assigned to value -1.
* @param test a complete or partial test case
* @return validity of the test case
*/
boolean isValid(final int[] test);
/**
* Calculate the number of violations in the candidate solution. Any unfixed
* parameter should be assigned to value -1.
* @param test a complete or partial test case
* @return number of constraints violations
*/
long penaltyTerm(final int[] test);
}
Specifically, the pre()
and post()
are the two methods that will be executed before and after test suite generation (namely, before and after invoking the process()
method of CAGenerator
), respectively. While the isValid()
and penaltyTerm()
are the methods that will be used to deal with constraints during test suite generation (namely, in the process()
method).
Verify | Solver | Tolerate | Replace | |
---|---|---|---|---|
pre |
Calculate MFTs | Initialise a SAT Solver | Calculate MFTs | Calculate MFTs |
isValid |
Check against MFTs | Solve a constraint satisfaction problem | True | True |
penaltyTerm |
Zero | Zero | Calculate based on MFTs | Zero |
post |
None | None | None | Replace invalid test cases |
We have implemented four constraint handlers, including Verify
, Solver
, Replace
, and Tolerate
, in CCAG as off-the-shelf choices. The concrete methods implemented in these four constraint handlers are shown in the above table.