Skip to content

Minimize exceptions in test methods signature #344

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

Closed
EgorkaKulikov opened this issue Jun 29, 2022 · 2 comments · Fixed by #418
Closed

Minimize exceptions in test methods signature #344

EgorkaKulikov opened this issue Jun 29, 2022 · 2 comments · Fixed by #418
Assignees
Labels
comp-codegen Issue is related to code generator

Comments

@EgorkaKulikov
Copy link
Collaborator

Description

The generated tests code looks as follows:

 public void testSetImage2() throws Throwable, Exception  { ... }

Throwing both Exception and Throwable is odd.
Can be reproduced with ContestEstimator on PDVisibleSignDesigner , method setImage

Expected behavior

The signature looks like

  1. if Throwable is really required
 public void testSetImage2() throws Throwable { ... } 
  1. if throwable is really not required
 public void testSetImage2() throws Exception  { ... }

Context

Possibly the reason of this problem is in

//If [InvocationTargetException] is thrown manually in test, we 
// to add "throws Throwable" and other exceptions are not required so on.
if (methodId == getTargetException) {
        collectedExceptions.clear()
        addException(Throwable::class.id)
        return
}
@EgorkaKulikov EgorkaKulikov added the comp-codegen Issue is related to code generator label Jun 29, 2022
@EgorkaKulikov EgorkaKulikov self-assigned this Jun 29, 2022
@EgorkaKulikov EgorkaKulikov moved this to Todo in UTBot Java Jun 29, 2022
@EgorkaKulikov
Copy link
Collaborator Author

public void testPDVisibleSignDesigner2() throws Exception, IOException

Another example on the same class

@EgorkaKulikov
Copy link
Collaborator Author

public void testPageHeightByFuzzer7() throws Exception, ClassNotFoundException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException

@EgorkaKulikov EgorkaKulikov changed the title Do not generate other throws in method signature if 'throws Throwable' is present. Minimize exceptions in test methods signature Jul 5, 2022
@EgorkaKulikov EgorkaKulikov linked a pull request Jul 5, 2022 that will close this issue
Repository owner moved this from Todo to Done in UTBot Java Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-codegen Issue is related to code generator
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants