Increase test coverage
Test generation icons next to methods in the editor work in IntelliJ IDEA, WebStorm, and PyCharm. Click the icon next to a method, and Explyt will offer to generate tests for that specific method.
This is handy when you want to quickly cover a particular method with tests without telling the agent where to find it.
Scenarios where this feature can be useful
- You are working with legacy code, planning to take it over for maintenance, and want to pin down the current behavior of the code so that you do not break it later
- You are refactoring complex code and want to guarantee that you will not break anything
- Your company has a quality gate for test coverage, for example 80%
How to use
- Next to a method or class, click the
Explyticon and selectExplyt: Analyze and Increase Test Coverage - The plugin finds the tests for this class and runs them with instrumentation to measure coverage
- Note: running the tests that were found may take some time. It may be slightly longer than a normal run of the same tests because of code instrumentation.
- The plugin displays line and branch coverage in the existing tests.
- Use
View covered linesbefore generation to see which parts are already covered and which are missed, to check partially covered branches, and to find out which existing tests reach a particular line. - Click
View covered lines. The analyzed method or class opens in a separate window: uncovered lines are highlighted in red, fully covered lines in green, and lines with partially covered branching in yellow. - Click the colored marker in the editor gutter next to a green or yellow line. Explyt shows the tests that cover this line; select a test to jump to its method.
- If a line has no color, its coverage does not make sense, for example because it is a field declaration.
- Use
- Click
Increase Test Coverage- The plugin starts generating additional tests
- During generation, the plugin adds new tests, runs them with instrumentation, and fixes errors
- The plugin displays the resulting line and branch coverage
- If coverage is still not high enough, you can continue the process by returning to step 3.
How is this different from simple AI scripts like Qodo-Cover?
The key difference lies in our use of formal mathematical methods.
Intuitively, tests and test data are generated using formal methods, and AI is used at the end to refine the resulting tests (to match the project style).
| Developer | Other tools | Explyt | |
|---|---|---|---|
| Generation method | Human effort | Pure AI | Formal methods + AI |
| Can generate tests from scratch? | Yes | Yes | Yes |
| Can "break through" code when coverage is already quite high? | No (won't, too time-consuming) | No | Yes |
| Is there a guarantee of increased coverage? | Probably not | No: tests are generated randomly | Yes: tests are generated to guarantee reaching uncovered lines |
| Time cost | Very high | High | Medium |
| Money cost | None | Yes, a lot on AI runs | Yes, a little at the end on AI refactoring |