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

Missing util class #881

Closed
ArsenHD opened this issue Sep 8, 2022 · 1 comment
Closed

Missing util class #881

ArsenHD opened this issue Sep 8, 2022 · 1 comment
Assignees
Labels
ctg-bug Issue is a bug status-duplicate This issue or pull request already exists

Comments

@ArsenHD
Copy link
Collaborator

ArsenHD commented Sep 8, 2022

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:

  1. Open some class, let's say class A.
  2. Make sure that tests on this class will need util methods (example of such class is org.utbot.examples.objects.PrivateFields).
  3. Make sure that no test class for our class A already exists (no class ATest).
  4. 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).
  5. Run test generation.
  6. As a result, you should get a test class that imports and uses some methods of util class UtUtils, but UtUtils 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:
image

The cause seems to be this exception:
image

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.

@korifey korifey moved this to Todo in UTBot Java Sep 8, 2022
@alisevych alisevych added ctg-bug Issue is a bug status-duplicate This issue or pull request already exists labels Sep 8, 2022
@alisevych
Copy link
Member

Duplicate of #879

@alisevych alisevych marked this as a duplicate of #879 Sep 8, 2022
@alisevych alisevych closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2022
Repository owner moved this from Todo to Done in UTBot Java Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ctg-bug Issue is a bug status-duplicate This issue or pull request already exists
Projects
Archived in project
Development

No branches or pull requests

3 participants