Skip to content

Invalid line separators in a custom JavaDoc tag prevent test generation #1001

Closed
@dtim

Description

@dtim

Description

For some code examples, invalid line separators are generated, presumably in

To Reproduce

Steps to reproduce the behavior:

Example:

Using the plugin, invoke test generation for the foo method:

class Foo {
     public void foo(@NotNull String[] data, Object item) {
        data[0] = (String) item;
    }
}

Expected behavior

Tests are successfully generated, no exceptions are thrown.

Actual behavior

No tests are generated, an exception is thrown and displayed in IDE:

java.lang.AssertionError: Wrong line separators: '...ct item) {\r\n *     d...' at offset 629
	at com.intellij.openapi.util.text.StringUtil.assertValidSeparators(StringUtil.java:2511)
	at com.intellij.openapi.editor.impl.DocumentImpl.assertValidSeparators(DocumentImpl.java:710)
	at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:604)
	at com.intellij.openapi.editor.impl.DocumentImpl.lambda$setText$2(DocumentImpl.java:1081)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:207)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:172)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:162)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:148)
	at com.intellij.openapi.editor.impl.DocumentImpl.setText(DocumentImpl.java:1086)
	at org.utbot.intellij.plugin.generator.CodeGenerationController$generateCodeAndReport$1$1$1$run$$inlined$executeCommand$default$1.run(actions.kt:14)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:216)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:172)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:162)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:148)
	at org.utbot.intellij.plugin.generator.CodeGenerationController$generateCodeAndReport$1$1$1.run(CodeGenerationController.kt:918)
	at org.utbot.intellij.plugin.util.IntelliJApiHelper$run$lambda-6$$inlined$runWriteAction$1.compute(actions.kt:60)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$runWriteAction$15(ApplicationImpl.java:945)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:924)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:945)
	at org.utbot.intellij.plugin.util.IntelliJApiHelper.run(IntelliJApiHelper.kt:58)
	at org.utbot.intellij.plugin.generator.CodeGenerationController$generateCodeAndReport$1$1.run(CodeGenerationController.kt:604)
	at org.utbot.intellij.plugin.util.IntelliJApiHelper$run$lambda-6$$inlined$invokeLater$1.run(ApplicationUtils.kt:69)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
	at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:794)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:350)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:133)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:189)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:885)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:754)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:441)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:825)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:440)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:794)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:486)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)```

Environment

  • Testing framework: JUnit 5
  • No mocks
  • Parametrized tests: off

Additional context

It seems that the summary with the custom tag @utbot.executesCondition may be incorrect for an execution (code has been taken from the debugger, breakpoint set at com.intellij.openapi.util.text.StringUtil#assertValidSeparators:2511; I am not sure but I suppose that this code probably can't be rendered because of the multiline string inside the @code tag).

    /**
    @utbot.classUnderTest {@link Foo}
 * @utbot.methodUnderTest {@link basic.Foo#foo(java.lang.String[],java.lang.Object)}
 * @utbot.executesCondition {@code (public void foo(@NotNull String[] data, Object item) {
 *     data[0] = (String) item;
 * }): False}
 *  */
    @Test
    @DisplayName("foo: ")
    public void testFoo() {
        Foo foo = new Foo();
        java.lang.String[] data = {null};
        
        foo.foo(data, null);
        
        String finalData0 = data[0];
        
        assertNull(finalData0);
    }
    ///endregion

Metadata

Metadata

Assignees

Labels

comp-summariesSomething related to the method names, code comments and display names generationctg-bugIssue is a bugpriority-blockerBug blocking some of the main features

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions