JetBrains-Research / TestSpark

TestSpark - a plugin for generating unit tests. TestSpark natively integrates different AI-based test generation tools and techniques in the IDE. Started by SERG TU Delft. Currently under implementation by JetBrains Research (Software Testing Research) for research purposes.
MIT License
54 stars 23 forks source link

`NullPointerException` on test case deletion #368

Open Vladislav0Art opened 2 months ago

Vladislav0Art commented 2 months ago

Describe the bug Deletion of a test case inflicted a NullPointerException.

To Reproduce I missed the entire sequence of actions that led to the error, but I did not follow, and the error occurred (these steps may not yield the error!):

  1. Generate tests via LLM.
  2. Go to the last one and request LLM to change it (I wrote "why does it fail?" prompt; maybe the test name or its member function name changed).
  3. Press delete button.
  4. See error.

Expected behavior Either a test case gets deleted or no-op.

Additional context See a full stack trace below; here is the part of our code:

java.lang.NullPointerException
    at org.jetbrains.research.testspark.display.generatedTests.GenerateTestsTabHelper.removeTestCase(GenerateTestsTabHelper.kt:11)
    at org.jetbrains.research.testspark.display.generatedTests.TestCasePanelBuilder.remove(TestCasePanelBuilder.kt:608)
    at org.jetbrains.research.testspark.display.generatedTests.TestCasePanelBuilder.getBottomPanel$lambda$10(TestCasePanelBuilder.kt:303)

The full stack trace is as follows:

java.lang.NullPointerException
    at org.jetbrains.research.testspark.display.generatedTests.GenerateTestsTabHelper.removeTestCase(GenerateTestsTabHelper.kt:11)
    at org.jetbrains.research.testspark.display.generatedTests.TestCasePanelBuilder.remove(TestCasePanelBuilder.kt:608)
    at org.jetbrains.research.testspark.display.generatedTests.TestCasePanelBuilder.getBottomPanel$lambda$10(TestCasePanelBuilder.kt:303)
    at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
    at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
    at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
    at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
    at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
    at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
    at java.desktop/java.awt.Component.processMouseEvent(Component.java:6657)
    at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3385)
    at java.desktop/java.awt.Component.processEvent(Component.java:6422)
    at java.desktop/java.awt.Container.processEvent(Container.java:2266)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5027)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
    at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4969)
    at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4583)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4524)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2809)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:794)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:733)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:766)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:764)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:763)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:698)
    at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.kt:637)
    at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$10(IdeEventQueue.kt:584)
    at com.intellij.openapi.application.impl.RwLockHolder.runWithEnabledImplicitRead(RwLockHolder.kt:138)
    at com.intellij.openapi.application.impl.RwLockHolder.runWithImplicitRead(RwLockHolder.kt:129)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:584)
    at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:77)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:362)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:361)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:843)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:361)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:356)
    at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1021)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:114)
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1021)
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:356)
    at com.intellij.openapi.application.impl.RwLockHolder.runIntendedWriteActionOnCurrentThread(RwLockHolder.kt:209)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:830)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:398)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
2024-09-24 16:02:12,466 [ 213451] SEVERE - #c.i.i.p.PluginManager - IntelliJ IDEA 2024.1  Build #IC-241.14494.240
2024-09-24 16:02:12,466 [ 213451] SEVERE - #c.i.i.p.PluginManager - JDK: 17.0.10; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.
2024-09-24 16:02:12,466 [ 213451] SEVERE - #c.i.i.p.PluginManager - OS: Mac OS X
2024-09-24 16:02:12,466 [ 213451] SEVERE - #c.i.i.p.PluginManager - Plugin to blame: TestSpark version: 0.2.1
2024-09-24 16:02:12,466 [ 213451] SEVERE - #c.i.i.p.PluginManager - Last Action: EditorBackSpace
dragoi75 commented 1 month ago

I could replicate the same issue by changing the generated test's name and then attempting to delete the test. It leads to the same error as above, and the test not being deleted:

java.lang.NullPointerException
    at org.jetbrains.research.testspark.display.generatedTests.GenerateTestsTabHelper.removeTestCase(GenerateTestsTabHelper.kt:11)
    at org.jetbrains.research.testspark.display.generatedTests.TestCasePanelBuilder.remove(TestCasePanelBuilder.kt:617)
    at org.jetbrains.research.testspark.display.generatedTests.TestCasePanelBuilder.getBottomPanel$lambda$10(TestCasePanelBuilder.kt:305)
Vladislav0Art commented 1 month ago

@dragoi75 Hi! Thanks for pointing to the reproduction steps! Taking this into work.