{"id":20859370,"url":"https://github.com/engineeringsoftware/predictiverts","last_synced_at":"2025-05-12T08:32:22.909Z","repository":{"id":114019219,"uuid":"477468215","full_name":"EngineeringSoftware/predictiverts","owner":"EngineeringSoftware","description":"ML-based regression test selection","archived":false,"fork":false,"pushed_at":"2024-07-11T13:36:55.000Z","size":218,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-07-11T15:39:32.429Z","etag":null,"topics":["machine-learning","ml","regression-test-selection","rts","testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EngineeringSoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-03T21:18:24.000Z","updated_at":"2024-07-11T13:36:59.000Z","dependencies_parsed_at":"2024-07-11T15:44:24.618Z","dependency_job_id":null,"html_url":"https://github.com/EngineeringSoftware/predictiverts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineeringSoftware%2Fpredictiverts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineeringSoftware%2Fpredictiverts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineeringSoftware%2Fpredictiverts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineeringSoftware%2Fpredictiverts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EngineeringSoftware","download_url":"https://codeload.github.com/EngineeringSoftware/predictiverts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225130723,"owners_count":17425506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["machine-learning","ml","regression-test-selection","rts","testing"],"created_at":"2024-11-18T04:49:38.766Z","updated_at":"2024-11-18T04:49:39.352Z","avatar_url":"https://github.com/EngineeringSoftware.png","language":"Python","readme":"# predictiverts\n\nML-based Regression Test Selection (RTS) models based on mutation\nanalysis and analysis-based RTS. [Link to the paper that describes the\ntechnique](https://dl.acm.org/doi/10.1145/3524481.3527230).\n\n## Installation\n\nIt is recommended to use [conda](https://docs.conda.io/en/latest) or\n[virtual\nenvironments](https://realpython.com/python-virtual-environments-a-primer)\nto manage Python dependencies.\n\nFor conda users, run:\n\n```bash\nconda create -n prts python=3.7\nconda activate prts\nconda install pip\npip install -r requirements.txt # you might have to point to pip that is in your conda env\n```\n\nTo run the experiments, you need Java 8 and Maven.  Also, you need a\nmachine with a GPU.\n\n## Training Data Collection\n\nWe use [PIT](https://pitest.org) to get mutants for training data. To\ngenerate and collect training data from an open-source project\n(`${project}` in the rest of this text):\n\n1. Create download directory `_downloads` and clone the repository\n`${project}` to this directory.\n\nThe list of projects and SHAs we used are documented\n[here](https://github.com/EngineeringSoftware/predictiverts/blob/43c65cc9bb2b7e1379e101457a734b7b2e01ad25/python/pts/main.py#L34).\n\nTo download all the projects with a single command, execute the\nfollowing:\n\n```bash\nmkdir -p _downloads\n./python/run.sh downloads_repos\n```\n\nYou will see 10 projects used in our paper downloaded to `_downloads`\nand the corresponding results directories in `_results`; the\n`_results` directory will be empty at this point.\n\n2. Enter the project's directory. Make sure to checkout to the correct\n   SHA of the `${project}` and the tests can be run without errors. We\n   use 'apache_commons-validator' for demonstration in the rest of\n   this document.\n\n```bash\ncd _downloads/apache_commons-validator\ngit checkout 97bb5737\nmvn test\n```\n\nYou should see the following as part of the output:\n```\n[INFO] Tests run: 527, Failures: 0, Errors: 0, Skipped: 0\n```\n\n3. Modifying the `pom.xml` file of the `${project}` by inserting the\n   following plugin to the `pom.xml`.\n\n```xml\n\u003cplugin\u003e\n\u003cgroupId\u003eorg.pitest\u003c/groupId\u003e\n\u003cartifactId\u003epitest-maven\u003c/artifactId\u003e\n\u003cversion\u003e1.7.1\u003c/version\u003e\n\u003cconfiguration\u003e\n  \u003cfullMutationMatrix\u003etrue\u003c/fullMutationMatrix\u003e\n  \u003coutputFormats\u003e\n    \u003cparam\u003eXML\u003c/param\u003e\n  \u003c/outputFormats\u003e\n\u003c/configuration\u003e\n\u003c/plugin\u003e\n```\n\n4. Run PIT and get a report in xml format `mutations.xml`.\n\n```bash\nmvn org.pitest:pitest-maven:mutationCoverage\n# You will find the report in _downloads/apache_commons-validator/target/pit-reports/$date/mutations.xml\n```\n\nYou should see the following as part of the output:\n```\n================================================================================\n- Statistics\n================================================================================\n\u003e\u003e Line Coverage: 2360/3030 (78%)\n\u003e\u003e Generated 2008 mutations Killed 1498 (75%)\n\u003e\u003e Mutations with no coverage 329. Test strength 89%\n\u003e\u003e Ran 37400 tests (18.63 tests per mutation)\n```\n\nYou can find more info about the `mutations.xml` on the PIT web\npage. In short, it contains details about generated mutants.\n\nThen copy the report (`mutations.xml`) to the result directory\n`_results/${project}`.\n\n```bash\ncd ../../\ncp _downloads/apache_commons-validator/target/pit-reports/*/mutations.xml _results/apache_commons-validator/\n```\n\n5. Parse the PIT report and the project's source code to collect the\n   pit-generated mutants.\n\n```bash\n./python/run.sh get_mutants apache_commons-validator\n```\n\nIf the script runs successfully, you will see `mutant-data.json` and\n`method-data.json` in the `_results/${project}/collector` directory.\n\nIn the example project, the following should be a part of the output:\n```\nIn total 1818 mutants recovered in project apache_commons-validator.\n```\n\n`mutant-data.json` contains information about mutants, e.g., list of\ntests that kill each mutant and those that do not kill it, context\n(i.e., mutated method).\n\n`method-data.json` contains methods from the repository, their\nargument types, etc.\n\n6. We provide positive and negative labels to each mutant-test\n   pair. For 'Ekstazi-\\*' models, we label the mutant-test pairs based on\n   RTS results, i.e., if the RTS tool (Ekstazi) select the test or not.\n\n- In order to run Ekstazi, copy the `tools/ekstazi-extension-1.0-SNAPSHOT.jar` to `${MAVEN_HOME}/lib/ext/` (i.e., if not set, `MAVEN_HOME` is the maven installation directory). Please refer to [document](tools/xts-extension/README.md) for more details.\n\n```bash\n# Collect labels from Ekstazi results\n./python/run.sh get_tools_data_for_mutants apache_commons-validator\n```\n\nIf the script runs successfully, you will see\n`mutant-data-rts-tool.json` file in\n`_results/${project}/collector`. This file is similar to\n`mutant-data.json`, but contains tests selected by Ekstazi.\n\n7. Create training and validation dataset\n\n- Dataset labeled by Ekstazi\n\n```bash\n./python/model_run.sh process_train_data_rank_model apache_commons-validator\n```\n\nYou will see text to stdout similar to the following:\n```\napache_commons-validator has 67 test classes in total.\nEkstazi\nIn total there are 19040 data point for training\nIn total there are 2838 data point for validation\n```\n\nThe actual output depends on the seed, which changes from run to run.\n\nThe output will be in\n`data/model-data/rank-model/commons-validator/Ekstazi/{train,valid}.json`.\n\n- Dataset labeled by tests pass or fail\n\n```bash\n./python/model_run.sh process_train_data_rank_model_fail apache_commons-validator\n```\n\nYou will see text to stdout similar to the following:\n```\nIn total there are 85980 data point for training\nIn total there are 8240 data point for validation\n```\n\nThe actual output depends on the seed, which changes from run to run.\n\nThe output will be in\n`data/model-data/rank-model/commons-validator/Fail/{train,valid}.json`.\n\n## Evaluation Data Preparation\n\n[sec-downloads]: #data-downloads\n\nTest data is hosted on UTBox via [a shared\nfolder](https://utexas.box.com/s/p0uvysksey7iz0l3fxxqo3k6p6xt78ji).\n\n1. Download eval data and put in the `evaldata` directory\n\n```bash\nmkdir -p evaldata\nunzip eval-data.zip -d evaldata\n```\n\n2. Process test data for a given project\n\n```bash\n./python/model_run.sh process_test_data_rank_model apache_commons-validator\n```\n\nThe processed evaluation dataset will be store at\n`data/model-data/rank-model/${project}/test.json`. This file is in a\nsimilar format as `test.json` and `valid.json`.\n\n## Model Training\n\n1. Train model with data labeled by Ekstazi\n\n```bash\n# train Ekstazi-Basic Model\n./python/model_run.sh train_rank_ekstazi_basic_model apache_commons-validator\n# train Ekstazi-Code Model\n./python/model_run.sh train_rank_ekstazi_code_model apache_commons-validator\n# train Ekstazi-ABS model\n./python/model_run.sh train_rank_ekstazi_abs_model apache_commons-validator\n```\n\nThe model checkpoints will be saved to\n`data/model-data/rank-model/${project}/Ekstazi-{Basic,Code,ABS}/saved_models`.\n\n2. Train model with data labeled by tests results\n\n```bash\n# train Fail-Basic Model\n./python/model_run.sh train_rank_fail_basic_model apache_commons-validator\n# train Fail-Code Model\n./python/model_run.sh train_rank_fail_code_model apache_commons-validator\n# train Fail-ABS model\n./python/model_run.sh train_rank_fail_abs_model apache_commons-validator\n```\n\nThe model checkpoints will be saved to\n`data/model-data/rank-model/${project}/Fail-{Basic,Code,ABS}/saved_models`.\n\n## BM25 Baseline Results on Evaluation Dataset\n\n1. Process evaluation data for BM25 baseline\n\n```bash\n./python/model_run.sh preprocess_bm25_baseline apache_commons-validator\n```\n\nThe processed data will be written to\n`evaldata/mutated-eval-data/f\"{project}-ag-preprocessed.json\"\n\n2. Run BM25 on the evaluation data\n\n```bash\n./python/model_run.sh run_bm25_baseline apache_commons-validator\n./python/model_run.sh analyze_BM25_model apache_commons-validator\n```\n\nThe results will be written to\n`results/modelResults/${project}/BM25Baseline/best-safe-selection-rate.json`.\n\nThe numbers (Baseline BM25) reported in the Table 4 ('best safe\nselection rate of models that select from subset of Ekstazi')\ncorrespond to the value of 'Ekstazi-subset-best-safe-selection-rate'\nin the file 'best-safe-selection-rate.json'.\n\nThe numbers (Baseline BM25) reported in the Table 5 ('best safe\nselection rate of models that select from subset of STARTS')\ncorrespond to the value of 'STARTS-subset-best-safe-selection-rate' in\nthe file 'best-safe-selection-rate.json'.\n\n## ML Models Evaluation\n\nRun evaluation:\n\n```bash\n./python/model_run.sh test_rank_ekstazi_basic_model apache_commons-validator\n./python/model_run.sh test_rank_ekstazi_code_model apache_commons-validator\n./python/model_run.sh test_rank_ekstazi_abs_model apache_commons-validator\n```\n\nThe eval results metrics will be written to\n`results/modelResults/${project}/Ekstazi-{Basic,Code,ABS}/best-safe-selection-rate.json`\nSame for 'Fail-\\*' models.\n\nThe numbers reported in the Table 4 ('best safe selection rate of\nmodels that select from subset of Ekstazi') correspond to the value of\n'Ekstazi-subset-best-safe-selection-rate' in the file\n'best-safe-selection-rate.json'.\n\nThe numbers reported in the Table 5 ('best safe selection rate of\nmodels that select from subset of STARTS') correspond to the value of\n'STARTS-subset-best-safe-selection-rate' in the file\n'best-safe-selection-rate.json'.\n\nDue to stochastic nature of models, the train-test loop should be\nrepeated a number of times and then averages, medians, and other\nstatistics should be considered.\n\n## Research\n\nIf you have used our data or code in a research project, please cite:\n\n```bibtex\n@inproceedings{ZhangETAL22Comparing,\n  author = {Zhang, Jiyang and Liu, Yu and Gligoric, Milos and Legunsen, Owolabi and Shi, August},\n  booktitle = {International Conference on Automation of Software Test},\n  title = {Comparing and Combining Analysis-Based and Learning-Based Regression Test Selection},\n  year = {2022},\n  pages = {17--28},\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengineeringsoftware%2Fpredictiverts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fengineeringsoftware%2Fpredictiverts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengineeringsoftware%2Fpredictiverts/lists"}