Skip to content
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

Junit test are not created if base project is on a path with "/test/" keyword #17

Open
kartikeytewari-ul opened this issue Jun 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@kartikeytewari-ul
Copy link
Contributor

kartikeytewari-ul commented Jun 27, 2024

Describe the bug

If a project is inside a path with /test/ string in it, then Junit test generation will not happen.

Video Demo is here. The stack trace is:

Failed to generate test case

java.lang.RuntimeException: java.lang.NullPointerException: Cannot invoke "java.util.Collection.toArray()" because "c" is null
	at com.insidious.plugin.ui.stomp.StompComponent.lambda$generateTestCaseSingle$22(StompComponent.java:1113)
	at com.intellij.openapi.project.DumbService.lambda$runReadActionInSmartMode$0(DumbService.java:112)
	at com.intellij.openapi.project.DumbService.lambda$runReadActionInSmartMode$1(DumbService.java:156)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:889)
	at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:69)
	at com.intellij.openapi.project.DumbService.runReadActionInSmartMode(DumbService.java:149)
	at com.intellij.openapi.project.DumbService.runReadActionInSmartMode(DumbService.java:112)
	at com.intellij.openapi.project.DumbService.tryRunReadActionInSmartMode(DumbService.java:129)
	at com.insidious.plugin.ui.stomp.StompComponent.generateTestCaseSingle(StompComponent.java:1107)
	at com.insidious.plugin.ui.stomp.StompComponent.onGenerateJunitTestCaseRequest(StompComponent.java:1067)
	at com.insidious.plugin.ui.stomp.StompComponent.lambda$createJunitFromSelected$6(StompComponent.java:430)
	at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:281)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:429)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:114)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressSynchronously$9(CoreProgressManager.java:513)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$new$0(ProgressRunner.java:84)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:252)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:252)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Collection.toArray()" because "c" is null
	at java.base/java.util.ArrayList.addAll(ArrayList.java:670)
	at com.insidious.plugin.factory.testcase.TestCaseService.buildTestCaseUnit(TestCaseService.java:274)
	at com.insidious.plugin.ui.stomp.StompComponent.lambda$generateTestCaseSingle$22(StompComponent.java:1109)
	... 32 more

Reproduction steps

  1. Create a project with path ~/test/unlogged-spring-maven-demo
  2. Direct Invoke any method
  3. Click on the Junit button, an exception will be thrown by Intellij IDE.
    ...

Expected behavior

Junit test case should have generated

Additional context

No response

@kartikeytewari-ul kartikeytewari-ul added the bug Something isn't working label Jun 27, 2024
@kartikeytewari-ul
Copy link
Contributor Author

RCA:

  • in TestCaseWriter class generateTestCaseBoilerPlace method a check on line-795 makes the return value null.
  • This method is invoked from TestCaseDesignerLite Class constructor from line-143.
  • The return value is null so line-145 breaks, and the catch-all messages get hit for test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant