Skip to content

Exceptions are thrown when trying to generate tests for abstract classes #550

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
volivan239 opened this issue Jul 19, 2022 · 0 comments · Fixed by #556
Closed

Exceptions are thrown when trying to generate tests for abstract classes #550

volivan239 opened this issue Jul 19, 2022 · 0 comments · Fixed by #556
Assignees
Labels
ctg-bug Issue is a bug

Comments

@volivan239
Copy link
Collaborator

Description

Currently, if you pass methods from abstract classes to tests generator, you are likely to have an uncaught exception that will ruin test generation

To Reproduce

Launch the plugin on a class C in this example:

abstract class C {
    abstract public int f();
}

class Cimpl extends C {
    @Override
    public int f() { return 0; }
}

Expected behavior

No tests are generated and C.f() is not even proposed for testing in dialog.

Actual behavior

Plugin shows a dialog with C.f() method. After launching plugin fails with IllegalArgumentException.

Visual proofs (screenshots, logs, images)

java.lang.IllegalArgumentException: Can't retrieve body for <rndpkg.C: int f()>
	at org.utbot.engine.ExtensionsKt.jimpleBody(Extensions.kt:114)
	at org.utbot.framework.util.SootUtilsKt.jimpleBody(SootUtils.kt:102)
	at org.utbot.engine.UtBotSymbolicEngine.<init>(UtBotSymbolicEngine.kt:157)
	at org.utbot.framework.plugin.api.TestCaseGenerator.createSymbolicEngine(TestCaseGenerator.kt:278)
	at org.utbot.framework.plugin.api.TestCaseGenerator.access$createSymbolicEngine(TestCaseGenerator.kt:51)
	at org.utbot.framework.plugin.api.TestCaseGenerator$generate$4$1$1.invokeSuspend(TestCaseGenerator.kt:166)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:84)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at org.utbot.common.ConcurrencyKt.runBlockingWithCancellationPredicate(Concurrency.kt:38)
	at org.utbot.framework.plugin.api.TestCaseGenerator$generate$4.invoke(TestCaseGenerator.kt:158)
	at org.utbot.framework.plugin.api.TestCaseGenerator$generate$4.invoke(TestCaseGenerator.kt:51)
	at org.utbot.common.ConcurrencyKt.runIgnoringCancellationException(Concurrency.kt:47)
	at org.utbot.framework.plugin.api.TestCaseGenerator.generate(TestCaseGenerator.kt:157)
	at org.utbot.framework.plugin.api.TestCaseGenerator.generate$default(TestCaseGenerator.kt:144)
	at org.utbot.intellij.plugin.generator.UtTestsDialogProcessor$createTests$2$1.run(UtTestsDialogProcessor.kt:196)
	at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:935)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsync$5(CoreProgressManager.java:442)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:235)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:170)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:629)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:581)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:157)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:235)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:834)

Environment

Generate for Java, JUnit5 with Mockito static mocking.

Additional context

Similar problems happen when you try to generate tests for abstract classes that has no implementations.

See also #221.

@korifey korifey moved this to Todo in UTBot Java Jul 19, 2022
@volivan239 volivan239 added the ctg-bug Issue is a bug label Jul 19, 2022
@volivan239 volivan239 self-assigned this Jul 19, 2022
Repository owner moved this from Todo to Done in UTBot Java Jul 28, 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
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant