{"id":15788397,"url":"https://github.com/lms24/jsr","last_synced_at":"2025-08-01T22:32:48.259Z","repository":{"id":45966246,"uuid":"395337472","full_name":"Lms24/JSR","owner":"Lms24","description":"JSR - The Java Test Suite Reduction Framework","archived":false,"fork":false,"pushed_at":"2021-11-23T20:29:33.000Z","size":1318,"stargazers_count":3,"open_issues_count":4,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-05T21:42:02.327Z","etag":null,"topics":["development-tools","java","test-suite-reduction","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lms24.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-12T13:59:57.000Z","updated_at":"2022-12-19T01:25:58.000Z","dependencies_parsed_at":"2022-09-23T08:53:31.748Z","dependency_job_id":null,"html_url":"https://github.com/Lms24/JSR","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/Lms24%2FJSR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lms24%2FJSR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lms24%2FJSR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lms24%2FJSR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lms24","download_url":"https://codeload.github.com/Lms24/JSR/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228413813,"owners_count":17915909,"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":["development-tools","java","test-suite-reduction","testing-tools"],"created_at":"2024-10-04T21:42:05.884Z","updated_at":"2024-12-06T04:51:51.959Z","avatar_url":"https://github.com/Lms24.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSR - The Java Test Suite Reduction Framework \n\nJSR is a test suite reduction framework for Java. It consists of the following modules:\n\n\n* JSR Core\n* JSR CLI\n* JSR IntelliJ IDE plugin\n\n\n## Important Notice:\n\nPlease note that JSR is currently still undergoing active Development. Features are subject to change and the installation process will change in the future. \nOur long-term goal is to create a test suite reduction framework for practical use in the software industry. If you want to contribute to JSR, please feel free to submit an issue or a PR. I would be happy if you want to get in touch with me.\n\n\n## JSR Core\n\nThe core framework module, containing the functionality and implementation of algorithms, interactions with programs, libraries, etc.\n\nMore specifically, the Core modules provides APIs to clients for the following features:\n\n* Test suite parsing and TS information collection\n* Coverage calculation\n* TSR calculation\n* Spectrum-based Fault Localization (SFL) Matrix export\n\n## JSR CLI\n\nA CLI frontend of the JSR framework, supporting the following features:\n\n* Test Suite Reduction\n  * Using different coverage metrics\n  * Using different TSR algorithms\n    * Greedy HGS\n    * Genetic \n* FSL Matrix export\n\n## IntelliJ IDE Plugin\n\nThe IntelliJ IDE Plugin serves as the front-end GUI. It directly integrates with \nIntelliJ so that developers can interact with JSR in a convenient and \nalready established way. The Plugin provides JSR-Core functionality with a few \nadditional features that only make sense in the IDE/GUI context:\n\n* Define and persist JSR settings (paths, package names)\n* Adjust TSR parameters (coverage type, TSR algorithm, Code generation)\n* Perform a fresh TSR round (including coverage report generation)\n* Perform  TSR round based on an already existent coverage report\n* List retained and redundant test cases after a TSR round\n* On click of a TC from the lists, the TC is opened up in the editor\n\n## Installation\n\nThis chapter outlines how to install JSR. All steps are required to set it up properly.\n\nPlease note that the installation process is subject to change as the project progresses.\n\n### 1. Requirements\n\n* Java JDK 11 \n  * make sure it is set as the default JDK version on your system\n  * make sure, `JAVA_HOME` points to your default JDK\n* Maven (required for building Slicer4J)\n* Gradle (required for building this project)\n\n### 2. JSR Installation\n\n1. Clone this repository and navigate to the project root directory\n\n```shell\ngit clone git@github.com:Lms24/JSR.git \ncd jsr\n```\n\n2. Execute the installation script to clone and build Slicer4J. \n\n```shell\nsh install.sh\n```\n\n3. Build the JSR project (this will build the Core, CLI and IntelliJ Plugin modules)\n   \nBefore building the actual project though, we need to initialize our testing environment so that the \nproject build can properly run the unit tests:\n   \n```shell\ncd jsr/JSR-Core/src/test/resources/smallProject\ngradle\ngradle build -x test\ngradle testJar\n```\n\nThen, we can finally build the JSR framework\n\n```shell\ncd ../../.././../.. #so that we're in the 'jsr' root directory \ngradle\ngradle build\n```\n\nCongratulations, JSR was built successfully.\n\nNote: The commands in step 3 can also be started by opening the \nrespective projects in IntelliJ and running the gradle tasks from the gradle plugin.\n\n## Starting the IntelliJ Plugin\n\nThe JSR IntelliJ plugin is not yet published. Thus, it cannot simply be installed into your IntelliJ IDE instance.\n\nCurrently, one has to start IntelliJ in sandbox mode to work with the JSR plugin. The easiest way is to run:\n\n```shell\ngradle JSR-IntelliJ-Plugin:runIde\n```\n\nAlternatively, when the JSR project is already opened in IntelliJ, \none can run the same gradle task from the gradle plugin.\n\n## Using the IntelliJ Plugin\n\nThe following rundown is based on the `smallProject` that is used for integration tests\nin the core library.\n\nTo try out the plugin, run IntelliJ as described above and open the `smallProject` \nunder `jsr/JSR-Core/src/test/resources/smallProject`.  \n\nThis project includes a test suite with around 15 tests of which many are purposefully \nredundant. \n\nOnce the project is loaded and IntelliJ finished building its indexes, open the JSR plugin. \nIt should be located either at the left or right hand side bars (\"JSR\").\n\n#### Settings\n\nJSR needs to know where some parts the project it should be ran on are located. The following \nlist explains the settings items (with example values for `smallProject`):\n\n* `Test Directory` is the root directory of your test suite. \n  For default Java projects this is usually similar to `project/src/test/java` \n  \n  Example: `smallProject/src/test/java`\n\n\n* `Source Directory` is the root source code directory of your project.\n  For default Java projects this is usually similar to `project/src/main/java` \n\n  Example: `smallProject/src/main/java`\n\n\n* `Jar File` is the path to your **fat jar**. This jar must contain the compiled **source and test classes**.  \n\n  Example: `smallProject/build/libs/testJar.jar`\n\n\n* `Classes Directory` is the path to your compiled java class files (required by JaCoCo)\n\n  Example: `smallProject/build/classes/java/main`\n\n\n* `Base Source Package` is the base package name of your project classes for which \n  line and method coverage should be calculated. You could use this as a filter if\n  you want to perform TSR based on only a part of your project's sources (i.e. a sub package). \n  \n  _This is an optional setting._\n\n  Example: `at.tugraz`\n\n\n* `Slicer Directory` is the path to Slicer4J. This helps JSR to find the \n  correct path to the slicer which is necessary to calculate checked coverage.\n\n  Example: `\u003cjsrProjectRoot\u003e/jsr/slicer/Slicer4J`\n\n\n* `Output Directory` is the path where all output files generated by JSR should be \n  written to. This directory will contain reports (coverage, Tsr), Exports (SFL) and \n  temporary files.\n  \n  Example: `smallProject/build/jsr/pluginTest01`\n\n\n* `Code Output Directory` is the path to the directory where the generated test \n  source code is written to. The generated sources are equal to the orginal test \n  suite sources with the exception of identified redundant test cases. Those\n  are deactivated via a JUnit annotation.\n  \n  Example: `smallProject/build/jsr/pluginTest01/gen`\n\n### Parameters\n\nUnder the `TSR Options` tab, you can specify your TSR parameters. \nThey should be pretty self expanatory. A short description can be found in the following list:\n\n* `Coverage Report Selection` determines which coverage report should be used for reduction:\n  * `New Report` will create a new coverage report with the selected coverage metric\n  * `Previous Report` will use a report that was generated in previous TSR runs.\n* `Reduction Algorithm` determines the employed algorithm in the reduction step\n  * Currently, you can choose between `Greedy HGS` and a `Genetic` algorithm.\n* `Deactivate redundant test cases` determines if test suite source code with redundant test cases\n  deactivated should be generated or not.\n  \n### Starting a TSR run\n\nAfter specifying the required settings and options parameters, you can start a TSR run by \nclicking the `Start TSR` button. Depending on whether a coverage report should be created, \nthis might take a while. \n\nOnce the TSR procedure is finished, two lists appear, one containing all relevant and thus _retained_ test cases\nand the other one, containing all identified _redundant_ test cases. Clicking on a test case in either list\nwill trigger a navigation to the test case source code in the IntelliJ editor window(s).\n\n## Using the CLI\n\nThe JSR command line interface can be used to leverage TSR core functionality via a command line tool. \nIt supports the same settings, parameters and core functionality as the IntelliJ IDE plugin.\n\nAdditionally, the CLI supports _Spectrum-based Fault Localization_ matrix export as a bonus feature for research purposes. \n\nUsage instructions can be found by running \n\n```shell\njava -jar JSR-CLI-1.0-SNAPSHOT.jar jsr --help\n```\n\nThis produces the following output:\n\n```shell\nUsage: jsr [-hV] [COMMAND]\n  -h, --help      Show this help message and exit.\n  -V, --version   Print version information and exit.\n  \nCommands:\n  reduce  Reduces a test suite based on the given options and parameters.\n  sfl     Creates Spectrum-based Fault Localization matrices.\n```\n\n### Performing TSR via the CLI\n\nBy invoking the `reduce` subcommand, the CLI can perform TSR: \n\n```shell\njava -jar JSR-CLI-1.0-SNAPSHOT.jar jsr reduce --help\n```\n\nThis produces the following output:\n\n```shell\nUsage: jsr reduce [-hV] [--algorithm=\u003calgorithm\u003e] -c=\u003cpathClasses\u003e [--coverage=\u003ccoverageMetric\u003e]\n                  [--gen=\u003cpathGenOut\u003e] -j=\u003cpathJar\u003e -l=\u003cpathSlicer\u003e -o=\u003cpathOut\u003e\n                  [--package=\u003cbasePackage\u003e] [--report=\u003cpathCoverageReport\u003e] -s=\u003cpathSources\u003e\n                  \u003ctestSourceDir\u003e\nReduces a test suite based on the given options and parameters.\n\n      \u003ctestSourceDir\u003e      The root directory of the test suite sources\n\n  -h, --help               Show this help message and exit.\n  -V, --version            Print version information and exit.\n\nRequired Parameters:\n  -c, --classes=\u003cpathClasses\u003e\n                           The path to the root directory containing the compiled source code\n                             classes\n  -j, --jar=\u003cpathJar\u003e      The path to the jar file containing the source and test classes\n  -l, --slicer=\u003cpathSlicer\u003e\n                           The path to the Slicer4J directory\n  -o, --out=\u003cpathOut\u003e      The path to the directory where all reports and output files are saved\n  -s, --sources=\u003cpathSources\u003e\n                           The root directory of the main source code\n\nOptional Parameters:\n      --algorithm=\u003calgorithm\u003e\n                           The reduction algorithm used to reduce the test suite.\n                             Available options: greedyHGS, genetic\n                             Default: greedyHGS\n      --coverage=\u003ccoverageMetric\u003e\n                           The coverage metric calculated before the reduction when no coverage\n                             report is specified. This option only has an effect if --report is not\n                             specified\n                             Available options: checked, line, method\n                             Default: checked\n      --gen=\u003cpathGenOut\u003e   The path to the directory where the modified test classes are generated\n                             and saved\n      --package=\u003cbasePackage\u003e\n                           When specified, only classes under this package are instrumented for\n                             line and method coverage calculation\n      --report=\u003cpathCoverageReport\u003e\n                           Path to the coverage report which is used for the reduction\n```\n\nA sample call to the CLI for reducing the `smallProject` test suite is provided below. The working \ndirectory of the command line in this example is `\u003cjsrProjectRoot\u003e/jsr`.\n\nThis example performs TSR with optional parameters: It creates a new line coverage report (`--coverage`)\nand employs the genetic reduction algorithm (`--algorithm`) that ships with JSR-Core. \nAdditionally, test suite source code is generated (`--gen`). \nThe `--package` option is set to the base package of the source code classes\nto slightly enhance JaCoCo instrumentation and test case execution performance\n\n```shell\njava -jar JSR-CLI-1.0-SNAPSHOT.jar jsr reduce\n-s JSR-Core/src/test/resources/smallProject/src/main/java\n-j JSR-Core/src/test/resources/smallProject/build/libs/testJar.jar\n-l ../slicer/Slicer4J\n-o JSR-CLI/build/jsr/cliTest01\n-c JSR-Core/src/test/resources/smallProject/build/classes/java/main\n--gen JSR-CLI/build/jsr/cliTest01/gen\n--package at.tugraz.ist.stracke.jsr\n--coverage line\n--algorithm genetic\nJSR-Core/src/test/resources/smallProject/src/test/java\n```\n### Generating SFL Matrices via the CLI\n\nThe CLI can generate Spectrum-based Fault Localization matrices by invoking the `sfl` subcommand:\n\n```shell\njava -jar JSR-CLI-1.0-SNAPSHOT.jar jsr sfl --help\n```\n\nThis produces the following output:\n\n```shell\nUsage: jsr sfl [-hV] -c=\u003cpathClasses\u003e -j=\u003cpathJar\u003e -l=\u003cpathSlicer\u003e -o=\u003cpathOut\u003e\n               [--package=\u003cbasePackage\u003e] -s=\u003cpathSources\u003e \u003ctestSourceDir\u003e\nCreates Spectrum-based Fault Localization matrices.\n\n      \u003ctestSourceDir\u003e   The root directory of the test suite sources\n\n  -h, --help            Show this help message and exit.\n  -V, --version         Print version information and exit.\n\nRequired Parameters:\n  -c, --classes=\u003cpathClasses\u003e\n                        The path to the root directory containing the compiled source code classes\n  -j, --jar=\u003cpathJar\u003e   The path to the jar file containing the source and test classes\n  -l, --slicer=\u003cpathSlicer\u003e\n                        The path to the Slicer4J directory\n  -o, --out=\u003cpathOut\u003e   The path to the directory where the SFL matrices are written to\n  -s, --sources=\u003cpathSources\u003e\n                        The root directory of the main source code\n\nOptional Parameters:\n      --package=\u003cbasePackage\u003e\n                        When specified, only classes under this package are instrumented for line\n                          and method coverage calculation\n```\n\nA sample SFL call is provided below. The `sfl` commands generates two CSV files: \n* `outcomeMatrix.csv` containing information about the outcome (pass/fail) of each executed test case.\n* `coverageMatrix.csv` containing the coverage data of each test case:\n  * A row of a _passing_ test case shows the _line-covered_ lines of the test case\n  * A row of a _failing_ test case shows the _checked-covered_ lines of the test case\n\n```shell\njava -jar JSR-CLI-1.0-SNAPSHOT.jar jsr sfl\n-s JSR-Core/src/test/resources/smallProject/src/main/java\n-j JSR-Core/src/test/resources/smallProject/build/libs/testJar.jar\n-l ../slicer/Slicer4J\n-o JSR-CLI/build/jsr/cliTest01\n-c JSR-Core/src/test/resources/smallProject/build/classes/java/main\n--package at.tugraz\nJSR-Core/src/test/resources/smallProject/src/test/java\n```\n\n\n## Credits\n### Libraries and Tools \n\nThe JSR project uses the following libraries and tools: \n\n* [Slicer4J](https://github.com/resess/Slicer4J) to perform dynamic slicing when calculating checked coverage (JSR Core)\n* [JaCoCo](https://www.eclemma.org/jacoco/) to calculate line and method coverage (JSR Core)\n* [JavaParser](https://javaparser.org/) to parse source code and test suites (JSR-Core)\n* [Jenetics](https://jenetics.io/) as a genetic algorithm library (JSR Core)\n* [Guava](https://github.com/google/guava) as a utility library for JSR Code  \n* [Jetbrains IntelliJ Platform SDK](https://plugins.jetbrains.com/docs/intellij/ide-development-instance.html?from=jetbrains.org)\n  for the JSR IntelliJ Plugin \n* [picocli](https://picocli.info/) as a CLI framework for the JSR CLI\n* [JUnit 5](https://junit.org/junit5/) and [Hamcrest](http://hamcrest.org/JavaHamcrest/tutorial) for testing (All Modules)\n* [Log4J](https://logging.apache.org/log4j/2.x/) for logging\n\n### Developed with\n\n* IntelliJ IDEA\n* OpenJDK\n* Sublime\n* GitHub\n* Love ❤️\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flms24%2Fjsr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flms24%2Fjsr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flms24%2Fjsr/lists"}