-
Notifications
You must be signed in to change notification settings - Fork 0
Home
muPLSQL is a tool for mutation testing of PL/SQL programs. The following figure depicts the main components of the tool and their ordered steps of interaction with databases.
The overall process for mutant generation and execution:
- Configuration is read
- The list of objects are read to generate mutants
- Mutants are generated and their names are kept in the database
- Generated mutants are saved to a given physical path in the working system
- Configuration is read for test case execution
- List of mutants are retrieved for their deployment on the database (steps from 7 to 8 are processed until all of the generated mutants are deployed and executed)
- Each mutant is read from the provided physical path and deployed to Testbed-DB
- Test case execution results are saved and status of the executed mutant is updated in Mutant-Status-DB
Testbed-DB and Mutant-Status-DB can be part of the same schema in the database or implemented as different schemas in Oracle database. Mutants-DB keeps the generated and saved source code files in physical path. Their names also are kept in Mutant-Status-DB. Configuration-DB keeps initial properties of the project, including the physical path info, working character set and database connection information.
- Version of Java Development Kit (JDK) >= 1.8
- Oracle Database instance >= Oracle 9i
Step 1: Configuration for database objects
- Create Tables
Run create_objects.sql file on the database. The file path is as follows:
https://github.com/arzutr/MuPLSQL/blob/master/DB/create_objects.sql
This script file creates database tables that are listed below.
Table Name | Table Content |
---|---|
TMUTATION | Database objects that are subject to mutation |
TMUTATION_OPERATIONS | Names of the created mutants and corresponding objects |
TMUTATION_OPERATORS | The set of defined mutation operators |
TMUTATION_TESTCASE | The list of test cases |
TMUTATION_TESTCASE_EXEC | Test execution results |
TMUTATION_OPERATOR_DETAIL | Mutation Operator configuration |
- Add definition to the TMUTATION table about database objects (package/procedure/function) that will be subject to mutation testing
Step 2: Configuration for Java Executable(muPLSQL)
- properties file (muPLSQL.properties) should contain mandatory properties listed in the following table.
- Database users must have access permission on the created database objects for mutation testing
- Physical paths regarding the source code should match with the list at the table TMUTATION Physical path is defined as the value of property SOURCE_FOLDER_NAME
Property name | Property Detail | Sample Data |
---|---|---|
SOURCE_FOLDER_NAME | Physical path to the source code of the project | C:\mutation_testing\source |
FILE_OPEN_CHARSET | File content character set | windows-1252 |
READ_FOLDER_NAME | Physical path of mutants for Test Case Execution | C:\mutation_testing\produced_ast\ |
WRITE_FOLDER_NAME | Physical path of mutants for Mutant Generation | C:\mutation_testing\produced_ast\ |
FILE_LOAD_CHARSET | File content character set | windows-1252 |
DB_USERNAME | Username of Mutant-Status-DB | muplsql |
DB_PASSWORD | Login password of Mutant-Status-DB | muplsql |
DB_URL | Connection information of Mutant-Status-DB (for Java application) | jdbc:oracle:thin:@localhost:1521:xe |
DB_MUTANT_USERNAME | Username of Testbed-DB | scott |
DB_MUTANT_PASSWORD | Login password of Testbed-DB | tiger |
DB_SCHEMA_NAME | Schema name of test case executor package (PKG_MUTATION) | hr |
DB_MUTANT_URL | Connection information of Testbed-DB (for Java application) | jdbc:oracle:thin:@localhost:1521:xe |
java -cp C:\Java\jdk1.8.0_251\bin;.\deploy\muPLSQL.jar;.\lib\ojdbc6.jar;.\muPLSQL\liblib\ora18n.jar;.\lib\spinatplsql_parser.jar org.muplsql.mg.WinMain &
When mutant generation is completed, created mutants are saved in the TMUTATION_OPERATIONS table on the database and changed source codes are saved in the physical path already defined for property value of WRITE_FOLDER_NAME.
When mutant generation is completed, the next step is to test mutants with existing test cases.
Two important steps exist:
- PKG_MUTATION should be deployed in the database and database users have a grant to execute all of objects defined in test cases
- Database connections and mutants file paths should be defined in muPLSQL.properties file
- The property value of WRITE_FOLDER_NAME should correspond to physical path of generated mutants
The following command can be used for executing test cases on the created mutants:
java -cp C:\Java\jdk1.8.0_251\bin;.\deploy\muPLSQL.jar;.\lib\ojdbc6.jar;.\muPLSQL\liblib\ora18n.jar; org.muplsql.mt.WinMainExecutor &
Test cases are composed of PL/SQL codes. RUN_TESTCASE_PRC method of PKG_MUTATION package is called and executed by muPLSQL for each deployed mutant on database.
PROCEDURE RUN_TESTCASE_PRC ( piov_object_name IN VARCHAR2,
piov_new_object_name IN VARCHAR2,
pion_mutant_id IN NUMBER,
P_ERR_MSG OUT VARCHAR2);
When test case execution is started, steps of test case execution are as follows:
- Read configuration file and connect to the database.
- Read mutants and follow the following steps for each mutant
- Deploy each mutant
- Execute test cases (Action performed by PKG_MUTATION is called from muPLSQL for each deployed mutant upon which results are inserted into the TMUTATION_TESTCASE_EXEC table)
- Update the status of each mutant in TMUTATION_OPERATIONS (value of IS_RUN column is updated from 0 to 1)
When RUN_TESTCASE_PRC method of the PKG_MUTATION package is called with mutant_id(pion_mutant_id),mutant_name(piov_new_object_name) parameters, corresponding test cases are retrieved from the database. PL/SQL code is generated to execute for each retrieved test case.
The sample generated PL/SQL code of test case as follows:
muPLSQL requires two definitions on database table and Java source code to be able to incorporate a new mutation operator.
Every Mutant generator class extends from the MITransformer class as depicted below.
A sample object diagram of MutationOperator Implementation is shown in the figure below.
There are four steps to implement a new mutation operator:
- Creating a new Java class file extends from MITransformer class for a new mutation operator
- Adding implementation such as specific properties of mutation operator into source code of Java class for a new mutation operator
- Adding a new class to the list of mutation operators in the OperatorLoader class
- Inserting a new record into the TMUTATION_OPERATORS table of Mutants-DB for created mutation operator