You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to cover SimpleCommentBuilder.kt, SimpleNameBuilder.kt, and SimpleClusterBuilder.kt with unit tests to capture the current behavior and make it easier to catch issues in the future.
I will try to do it using UTBot and on my own as well.
UTBot couldn't generate any tests for SimpleCommentBuilder.kt.
Environment:
JDK version: Amazon Coretto 1.8
UTBot version: 2022.7-beta
IDE version: IntelliJ Community 2022.1.3
Build #IC-221.5921.22, built on June 21, 2022
Runtime version: 11.0.15+10-b2043.56 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
It shows same error report for several methods:
///region Errors report for genWarnNotification
public void testGenWarnNotification_errors()
{
// Couldn't generate some tests. List of errors:
//
// 1 occurrences of:
/* class org.utbot.framework.plugin.api.UtCompositeModel cannot be cast to class org.utbot.framework.plugin.api.UtModel (org.utbot.framework.plugin.api.UtCompositeModel is
in unnamed module of loader java.net.URLClassLoader @6abba1ec; org.utbot.framework.plugin.api.UtModel is in
unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @4e9c8dd5) */
}
@sergeypospelov could you please help with it? should I create an issue for it?
UTBot also failed to generate tests for SimpleNameBuilder.kt
Error report:
///region Errors report for conditionStep
public void testConditionStep_errors() {
// Couldn't generate some tests. List of errors:
//
// 6 occurrences of:
// Default concrete execution failed
// 4 occurrences of:
/* Error in the child process |> org.mockito.exceptions.base.MockitoException: Mockito cannot mock
this class: class org.utbot.framework.plugin.api.Step. Can not mock final classes with the
following settings : - explicit serialization (e.g. withSettings().serializable()) - extra
interfaces (e.g. withSettings().extraInterfaces(...)) You are seeing this disclaimer because Mockito is
configured to create inlined mocks. You can learn about inline mocks
and their limitations under item #39 of the Mockito class
javadoc. Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [class
org.utbot.framework.plugin.api.Step]
at org.utbot.framework.concrete.MockValueConstructor.generateMockitoMock(MockValueConstructor.kt:220)
at org.utbot.framework.concrete.MockValueConstructor.constructObject(MockValueConstructor.kt:166)
at org.utbot.framework.concrete.MockValueConstructor.construct(MockValueConstructor.kt:127)
at org.utbot.framework.concrete.MockValueConstructor.constructMethodParameters(MockValueConstructor.kt:104)
at org.utbot.framework.concrete.UtExecutionInstrumentation.invoke(UtExecutionInstrumentation.kt:144)
at org.utbot.framework.concrete.UtExecutionInstrumentation.invoke(UtExecutionInstrumentation.kt:107)
at org.utbot.instrumentation.process.ChildProcessKt.loop(ChildProcess.kt:133)
at org.utbot.instrumentation.process.ChildProcessKt.main(ChildProcess.kt:77)
at org.utbot.instrumentation.process.ChildProcessKt.main(ChildProcess.kt)
Caused by: org.mockito.exceptions.base.MockitoException: Could not modify all classes [class org.utbot.framework.plugin.api.Step]
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:158)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:372)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:180)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:383)
... 9 more
Caused by: java.lang.IllegalStateException: Byte Buddy could not instrument all classes
within the mock's type hierarchy This problem should never occur for
javac-compiled classes. This problem has been observed for classes that
are: - Compiled by older versions of scalac - Classes
that are part of the Android distribution
at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.triggerRetransformation(InlineBytecodeGenerator.java:280)
at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.mockClass(InlineBytecodeGenerator.java:213)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.lambda$mockClass$0(TypeCachingBytecodeGenerator.java:47)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:158)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:372)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:180)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:383)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:40)
at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.createMockType(InlineDelegateByteBuddyMockMaker.java:389)
at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.doCreateMock(InlineDelegateByteBuddyMockMaker.java:349)
at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.createMock(InlineDelegateByteBuddyMockMaker.java:328)
at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.createMock(InlineByteBuddyMockMaker.java:56)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:53)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:96)
at org.mockito.Mockito.mock(Mockito.java:1964)
at org.mockito.Mockito.mock(Mockito.java:1937)
... 9 more
Caused by: java.lang.NoClassDefFoundError: Lsoot/jimple/Stmt;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2611)
at java.lang.Class.getDeclaredFields(Class.java:1944)
at net.bytebuddy.description.type.TypeDescription$ForLoadedType.getDeclaredFields(TypeDescription.java:8797)
at net.bytebuddy.dynamic.scaffold.InstrumentedType$Factory$Default$1.represent(InstrumentedType.java:437)
at net.bytebuddy.ByteBuddy.redefine(ByteBuddy.java:867)
at net.bytebuddy.ByteBuddy.redefine(ByteBuddy.java:842)
at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.transform(InlineBytecodeGenerator.java:382)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:144)
at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.triggerRetransformation(InlineBytecodeGenerator.java:276)
... 24 more
Caused by: java.lang.ClassNotFoundException: soot.jimple.Stmt
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 37 more
*/
}
Unfortunately, it's impossible to use UtBot on our project with UtSettings.useConcreteExecution set to true. It's our internal problem and is quite complex. Looks like setting this option to false might help. It can be found in UtSettings.kt.
Activity
onewhl commentedon Jul 19, 2022
UTBot couldn't generate any tests for
SimpleCommentBuilder.kt.Environment:
It shows same error report for several methods:
@sergeypospelov could you please help with it? should I create an issue for it?
onewhl commentedon Jul 19, 2022
UTBot also failed to generate tests for
SimpleNameBuilder.ktError report:
sergeypospelov commentedon Jul 19, 2022
Unfortunately, it's impossible to use UtBot on our project with
UtSettings.useConcreteExecutionset totrue. It's our internal problem and is quite complex. Looks like setting this option tofalsemight help. It can be found inUtSettings.kt.Add unit tests for SimpleNameBuilderTest #543
Add unit tests for SimpleClusterCommentBuilderTest.kt and SimpleComme…
Add unit tests for builders #543 (#734)
Add unit tests for builders #543 (#734)