How to create a XDebugSession or XStackFrame for testing?
Answered
I have created a plugin for visualizing the debugging variables during a debugging session. So far, I have tested the plugin manually.
I want to convert my manual testing to JUnit tests. However, I do not know how/if I can create an XDebugSession or XStackFrame programmatically as if I were debugging through the IDE.
I would like to start a debugging session for a given class file in a given line and then use the associated XStackFrame for my testing.
Maybe someone has an idea how to do this. I do not think the debugger is tested manually when an IntelliJ release happens, so I am nearly certain that this should be possible somehow.
Thanks in advance for any help or suggestions!
Please sign in to leave a comment.
See com.intellij.debugger.DebuggerTestCase and inheritors in IntelliJ Community sources for plenty of Debugger testing code
Thanks I will have a look!
HI Tim Kräuter,
were you successful in creating the test case by following that class ??
can you pls guide let me to know how you did this?
Thanks in advance for any help or suggestions!
Was a bit busy with other stuff. My current progress can be found here .
Not working yet for some reason but I did not have proper time to look into it. I will post an update once its working for me.
Thank you Tim Kräutern. seen your work, a very cool plugin.
I am also stuck at this testing part.
Ok, meanwhile I will also check.
Thanks
Hi,
I am still struggling to make this work. I tried a similar approach as the class TraceExecutionTestCase.
You can find my current implementation here. The problem is that the test case never finishes because the debug session never pauses.
However, the java file with a comment line indicating a breakpoint gets loaded successfully (see here).
Maybe someone can hint at what I'm doing wrong or a better class to use as a starting point?
Thanks in advance!
Are you getting a 'timeout' problem? I got a similar problem
I got the timeout problem initially but later timeout problem was solved have some other issues.
https://github.com/bhanuunrivalled/checktest/blob/main/src/test/java/com/github/bhanuunrivalled/checktest/TraceExecutionTestCase.java
There are implementations of DescriptorTestCase in Kotlin language plugin (use IJ Community master sources to obtain), see
community/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/KotlinDescriptorTestCase.kt
When I run your code I get the following exception:
When I run my test case it neither finishes nor timeouts. Not sure how to proceed at the moment.
Tim Kräuter Unfortunately, these test base classes expect to run inside IntelliJ Project itself, and there's currently no workaround.
Thanks for the information. Then I have to come up with a different way.