UnitTestBot / UTBotJava

Automated unit test generation and precise code analysis for Java
Apache License 2.0
133 stars 39 forks source link

Add setting to switch between Spring specific and regular Java flow #2472

Open alisevych opened 1 year ago

alisevych commented 1 year ago

Description

In Settings -> Tools -> UnitTestBot:

Expected behavior

If Spring support setting is turned ON - and the project has Spring dependencies - Spring-specific test generation should be applied. Action dialog should be changed to Spring-specific. Parameterized tests should not be displayed.

In all other cases - regular Java test generation should be applied. Action dialog UI should be regular, without Spring-specific logic and controls.

Environment

IntelliJ IDEA Ultimate / Community Projects with and without Spring dependencies

Potential alternatives

Currently there are two plugin JAR-files generated: with and without Spring support. It is not the best solution for several reasons:

  1. User should install/reinstall plugin - if they first used it in a Java project - and then want to use it in Spring project. Or vice a versa.
  2. Several artefacts support.

Context

See https://github.com/UnitTestBot/UTBotJava/actions/runs/5735792610

image

Both IU and IC plugins can be installed on IntelliJ IDEA Ultimate and Community. Plugin size with and without Spring differs not critically: 34 MB maximum (168 vs 134)

EgorkaKulikov commented 1 year ago

Actually, I do not really see an outcome of the following feature. Giving an option to generate standard tests for Spring projects may be useful if we consider our Spring specific implementation to be bad and our standard implementation to generate something meaningful at once. I'm not sure that Spring specific version is so bad and standard version is so good...

However, it may be a good feature to allow selecting generation type for the current class selected in editor, as user may see that it does not have any Spring specific or contains something we have difficulties to deal with. When we generate tests not for one class, but for whole packages, this arguments are not actual any more. so a feature seems to be useless to me.

alisevych commented 1 year ago

Agreed. And there is one more reason for a user to select regular flow in a Spring project. That can be generated tests format preferences. User may select to generate regular unit tests without @InjectMocks and @Mock