Description
Description
Not long ago we implemented an util class. Basically, this is a class that contains all util methods required by test classes. The problem is that sometimes this class is not generated, which leads to compilation failure for test classes that use some methods from util class.
To Reproduce
This bug only happens when there is no test class that already exists for our class under test.
Steps to reproduce the behavior:
- Open some class, let's say class
A
. - Make sure that tests on this class will need util methods (example of such class is
org.utbot.examples.objects.PrivateFields
). - Make sure that no test class for our class
A
already exists (no classATest
). - Make sure that no util class already exists in any of the test source roots of the current module (no class
org.utbot.runtime.utils.UtUtils
). - Run test generation.
- As a result, you should get a test class that imports and uses some methods of util class
UtUtils
, butUtUtils
would not exist, because we failed to generate it.
Expected behavior
When test class needs util class, but util class does not yet exist, an util class UtUtils
should be generated.
Actual behavior
Test class that uses UtUtils
is generated, but class UtUtils
is not.
Visual proofs (screenshots, logs, images)
When generating tests for org.utbot.examples.objects.PrivateFields
:
The cause seems to be this exception:
It seems that when we attempt to reformat the test class, the thread we are doing it in stops due to this exception, which leads to all the further actions (like util class generation) to be skipped.
NOTE that when the test class already exists (so we rewrite it with a new one), this exception is not thrown and util class is generated successfully.
Environment
This bug happens in IntelliJ plugin. Steps to reproduce it are given above.
Additional context
Class org.utbot.examples.objects.PrivateFields
should be enough to test this bug. But if you want to check the behavior on other classes, then tests on your classes should need util class. For that purpose write methods that depend on some private fields or private classes so that we will have to use util class in order to work with them via reflection.
Metadata
Metadata
Assignees
Type
Projects
Status