Skip to content

Skip test generation for abstract methods #550 #556

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

Merged

Conversation

volivan239
Copy link
Collaborator

@volivan239 volivan239 commented Jul 19, 2022

Description

  • Added filters for abstract methods, so now they don't reach test generator
  • Added catch for exception which is thrown when plugin tries to generate tests for an abstract class that has no implementations (in this case error message is shown in UI)

Fixes #550

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Automated Testing

No tests were added.

Manual Scenario

Checklist (remove irrelevant options):

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • New documentation is provided or existed one is altered
  • No new warnings
  • New tests have been added
  • All tests pass locally with my changes

@volivan239 volivan239 requested a review from Damtev July 19, 2022 16:02
@volivan239 volivan239 marked this pull request as ready for review July 19, 2022 16:03
@@ -361,6 +362,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
if (srcClasses.size == 1) {
items = TestIntegrationUtils.extractClassMethods(srcClasses.single(), false)
.filterWhen(UtSettings.skipTestGenerationForSyntheticMethods) { it.member !is SyntheticElement }
.filterNot { it.member.modifierList?.hasModifierProperty(PsiModifier.ABSTRACT)?: false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move such a function somewhere in utils.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to org.utbot.intellij.plugin.util.MemberInfoUtilsKt#isAbstract

.map { it.summarize(searchDirectory) }
.filterNot { it.executions.isEmpty() && it.errors.isEmpty() }
}
} catch (e: java.lang.IllegalStateException) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we really going to catch only IllegalStateException? Maybe, we should catch every exception here? Need to discuss

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, replaced with runCatching

@volivan239 volivan239 force-pushed the volivan239/skip_test_generaton_for_abstract_methods branch from 5ad8aae to ff6f2cd Compare July 28, 2022 12:45
@volivan239 volivan239 merged commit af1b2b3 into main Jul 28, 2022
@volivan239 volivan239 deleted the volivan239/skip_test_generaton_for_abstract_methods branch July 28, 2022 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Exceptions are thrown when trying to generate tests for abstract classes
2 participants