Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kex Integration #294

Open
wants to merge 57 commits into
base: development
Choose a base branch
from

Conversation

edwin1729
Copy link

@edwin1729 edwin1729 commented Jul 12, 2024

Integrating Kex (Symbolic Execution) into TestSpark

Generates test cases using Kex and displays them in the TestSpark tool window

Summary of changes

The integration of kex follows the example of EvoSuite and LLM for teh most part, so I highlight just the kex specific parts.

  • A third party java parser is used for preprocessing of generated test files. For each generated test class, the fields @before @test annotated methods are rewritten into a single test method
  • TestGenerationData.otherInfo contains all the helper methods and a static initializer. This shows up in each test case in tool window for compilation and exactly once in the generated test file if "apply to test suite" is chosen
  • To make the test cases in the tool window readable even with the large amount of helper code
    Automatic folding (hiding behind ...) of all code other than test annotated methods in the tool window is implemented. This is using the PsiFile for each test case
  • There are additional fields added to the implementations of PsiMethodWrapper (and implementations) because kex requires specification of the method for which tests are generated in a specific format. Namely it involves FQNs and an example is given here: org.example.Matrix::product(org.example.Matrix,java.util.function.BinaryOperator,java.util.function.BinaryOperator):org.example.Matrix
    Note also that types have been erased. Kex expects JVM types which is easy to get from Java types but not from kotlin. For this reason kotlin is not yet supported by kex.
  • Kex is released as zip file, so it is downloaded and unpacked into the OS-specific cache directory (~/.cache on unix, LOCALAPPDATA in windows). Also note it doesn't currently support ARM linux (but does support ARM mac)
  • Kex uses .class files to generate tests, so the build directory for the correct module is obtained from IJ API

Needs debugging and testing
* load kex-runner jar from github (build.gradle.kts toplevel)
* setup code for kex properties
* KexErrorManager based on LLMErrorManager
* KexProcessManager based on EvoSuiteProcessManager
* Basic UI element (button for running kex)
* kex works only for the class codeType (todo funciton and line if possible)
* read resource files kex.policy and modules.info
use a provided kex path for now instead of downloading jar and adding dependency
use ProcessBuilder (jdk) instead of OSProcessHandler (IJ sdk)
use kex.py instead of building java command directly
generate Report objects by reading generated java classes
Deleted stuff:
running Kex through through OSProcessHandler (IJ sdk)
running Kex with kex.py
downloading kex from github in build.gradle.kts
@edwin1729 edwin1729 changed the title Edwin1729/improvement/kex integration Kex Integration Jul 12, 2024
@edwin1729 edwin1729 force-pushed the edwin1729/improvement/kex-integration branch from e623ee7 to 237e549 Compare July 24, 2024 07:49
@edwin1729 edwin1729 force-pushed the edwin1729/improvement/kex-integration branch from 935b0c9 to b766057 Compare July 24, 2024 12:01
@arksap2002
Copy link
Collaborator

Closes #328

@arksap2002 arksap2002 added In progress PR is in progress and removed Ready for review PR redy for review labels Sep 3, 2024
@arksap2002 arksap2002 self-requested a review September 18, 2024 14:03
@arksap2002 arksap2002 added improvement New feature Ready for review PR redy for review and removed In progress PR is in progress labels Sep 18, 2024
@Vladislav0Art Vladislav0Art removed the Ready for review PR redy for review label Oct 8, 2024
@arksap2002 arksap2002 added Ready for review PR redy for review In progress PR is in progress and removed Ready for review PR redy for review labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement New feature In progress PR is in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants