This is the reproduction package for the paper "Evaluating the Trade-offs of Text-based Diversity in Test Prioritisation" by Khojah et al. The package includes scripts to run Jaccard, NCD, Levenshtein, Random and Semantic Similarity (using NLP) as well as the Doc2Vec model that was used to perform Semantic Similarity. Scripts to measure the coverage, failures and execution time of each technique on 3 levels of testing are also included
-
Anaconda shell is preferable to run the programs
-
The program runs on Julia 1.5 or latest
-
The following packages should be installed
Package Version docker 20.10
- cd to
src/distance_measures/
- Locate your test files in
data/
directory - Run
sh lexical_distance_measures.sh
-
Anaconda shell is preferable to run the programs
-
The program runs on Python 3.7 or latest
-
The following packages should be installed
Package Version gensim 3.8.1 jupyter 1.0.0 sklearn 0.0 numpy 1.18.1 pandas 1.0.3 nltk 3.4.5 regex 2017.4.5 stop-words 2018.7.23 tensorflow 2.1.0 sent_tokenize stem 1.8.0
The pretrained model in .bin
format and relevant files are available here.
- cd to
test-prioritization-tools/src/SS/python
- Locate your set in a folder called
dir
in the same location whered2v.py
is located - Each test description file should correspond to one test case and in .txt format
- Run
d2v.py
viapython d2v.py
A csv file that includes a distance matrix calculated by cosine distance function.
- interpret the distance matrix into a ranking by running the
Julia mdistmain.jl distance_matrix.csv
in Julia folder - Create a random ranking by cd to
test-prioritization-tools/src/Random
then placingdir
as a test suite folder and finally runpython random_test_specs.py
. - Calculate the coverage of the generated ranking.
There are 2 coverage scripts that can be used for 2 different formats of tests:
- [ Company A ] Extracting system-level tests from seperate text files in a directory.
- [ Company B ] Extracting integration-level tests from a test suite and the corresponding system-level tests from the docstrings of each test in the test suite.
We also provide the R scripts in src/coverage/coverage_visualization/coverage_plot/
to visualize the coverage on a system and integration level along with the input in company_A_and_B_plots.zip
zip file (needs to be unzipped) to regenerate the plots in the paper.
- cd to
src/coverage/
- run
python check_coverage_companyA
orpython check_coverage_companyB
* Note that the coverage scripts expect a ranking of the tests and a mapping of the tests to the requirement / feature covered.
- cd to
src/Random/
- Run python
random_test_spec.py <path_to_directory_with_test_files>
- The script will run Random 10 times (could be adjusted in the code)
- The output is a folder
randomfiles/
with 10 files of 10 random rankings of the test files
Defects4j needs to be set up first. The scripts are shell scripts, and thus require bash.
- Checkout all versions of a project with
checkoutallfixedversions.sh
- Accepts 3 parameters all 3 required
- Project identifier to checkout
- Starting bug version
- Ending bug version
- Must make parent directory first, needs to be labelled the same as project identifier
- Versions will be inside that folder
- Test each version with
testprojects.sh
- Takes 1 parameter, required
- Target directory of where all the checked out versions are
- Need to do this to get all_tests.
- Retrieve a list of method names with
renamealltests.sh
- Takes 1 parameter, required
- Target directory of where the parent directory is
- Example: Lang > lang1, lang2, lang3
- Lang is the parent directory
- Target directory of where the parent directory is
- Folder called “methlist” must be created beforehand in the same place where renamealltests is
- Restructure/reorganize the list with
reorgmethlist.sh
- Accepts 1 parameter, required
- Target directory of where the extracted method name lists are
reorgmethlist.sh
usesmethodlist.awk
- To run
methodlist.awk
itself, use awk file withawk -f methodlist.awk [location of methodlist file]
. reorganizedMeths/
folder should already be created
- Separate methods by running
felixMethSep
- Before running the tool:
- Put all the restructured methodlists into
target/surefire-reports
- Copy all the respective checked out versions of corresponding projects to
target/projects_to_separate.
The entire projects.
- Put all the restructured methodlists into
- Run the maven project. Its a maven project.
- The resulting code will be in
target/pit-reports/code
.
- Ranking.
- Depending on technique, 3 choices:
Jaccarddivseq.sh
,levendivseq.sh
,ncddivseq.sh
,randomdivseq.sh
- Accepts 1 argument, required
- Target directory where all directories of the extracted code is, 1 level deep.
- Generates both the rankings and execution time, which is outputted into a different file of just the stdout
- Randomdivseq generates the rankings in
rankedtests/
- Preprocess for Failures - sort rankings -
rankedtests/sortrankings.sh
- Ranking csv needs to be sorted in ascending order for easier processing
- Accepts 1 argument, required - target directory where all rankings are stored
- Preprocess - Add “technique” column, shift other columns right -
rankedtests/shiftcolright.sh*
- Accepts 1 argument, required: target directory
- Preprocess - Generate csv containing a list of all triggering tests for all versions of a project
- Checkout to bugs_csv branch of defects4j at the time of writing
- Run
defects4j query -p [project] -q “trigger_tests” > [project]\_triggers.csv
- Replace “::” with “.” for each method in the trigger csv -
doublecolontoperiod.sh
- Accepts 1 argument - target directory of triggers csvs
- Find where triggers are in the ranking
totalfailures.sh/totalfaults.sh
- Accepts 3 arguments,required
- Trigger csv file location
- Target directory where sorted,tech col added ranking csvs are
- Project id
- Merge all techniques of a ranked technique csv into 1 csv -
mergetechs.sh
- 2-4 argument, required - targetdir of dir of each technique ranked file
- Will take first folder as master
- Slaves will look for version number of master
- Make test case names all the same without breadcrumbs -
shortentestnames.sh*
- Targetdir of where merged ranked failures or faults are
A text file for each version containing the execution time should have been created
- Put all of the raw execution text files in a subfolder in
metrics/
- Use
extracttime.sh
for techniques executed once - use
batchextracttime.sh
for techniques executed > 1, like Random.
- Convert all_tests to reusable coverage method format -
covreorgmethlist.sh
- execute coverage for each test -
coverage.sh
- Text file generated containing condition and line coverage