Otherwise, `org.jetbrains.kotlin.idea.testGenerator.all.AllTestsGeneratedTest.testAllTestsIsUpToDate` fails with an error like: ``` com.intellij.platform.testFramework.core.FileComparisonFailedError: 'GradleBuildFileHighlightingTestGenerated.java' is not up to date Use 'Generate Kotlin Tests' run configuration to regenerate tests at org.jetbrains.kotlin.testGenerator.generator.TestGeneratorKt.write(TestGenerator.kt:156) at org.jetbrains.kotlin.testGenerator.generator.TestGenerator.write(TestGenerator.kt:72) at org.jetbrains.kotlin.testGenerator.generator.TestGenerator.write(TestGenerator.kt:32) at org.jetbrains.kotlin.fe10.testGenerator.Fe10GenerateTestsKt.generateK1Tests(Fe10GenerateTests.kt:172) at org.jetbrains.kotlin.idea.testGenerator.all.AllTestsGeneratedTest.testAllTestsIsUpToDate(AllTestsGeneratedTest.kt:10) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at junit.framework.TestCase.runTest(TestCase.java:177) at junit.framework.TestCase.runBare(TestCase.java:142) at junit.framework.TestResult$1.protect(TestResult.java:122) at junit.framework.TestResult.runProtected(TestResult.java:142) at junit.framework.TestResult.run(TestResult.java:125) at junit.framework.TestCase.run(TestCase.java:130) at junit.framework.TestSuite.runTest(TestSuite.java:241) at junit.framework.TestSuite.run(TestSuite.java:236) at com.intellij.TestAll.runOrCollectNextTest(TestAll.java:399) at com.intellij.TestAll.run(TestAll.java:280) at junit.framework.TestSuite.runTest(TestSuite.java:241) at junit.framework.TestSuite.run(TestSuite.java:236) ``` GitOrigin-RevId: c8a0adce00acd8196ac923bf62425f682be70931
Kotlin debugger tests
This module contains generated tests for Kotlin debugger.
Tests design lets one add debugger markup directly in a code sample.
For example, breakpoint installation is done with //Breakpoint! marker on the line previous to the target one.
Tests are separated into different categories depending on tested functionality, e.g. stepping, evaluation, smart-step-into targets, local variables, highlighting, etc.
To create a new test:
- Choose the target functionality to test and the corresponding subdirectory inside
testDatafolder - Create a
<FILE_NAME>.ktfile with the code sample to test - Add the markup specific for the target functionality. Check the available capabilities in the nearby files.
- Create a
<FILE_NAME>.outfile with the expected output. Check the expected output format in the nearby files. - Start
Generate Kotlin Tests (K1 + K2)run configuration
Markup
Stepping
//Breakpoint!installs a breakpoint to the next line. Breakpoint can be configured further:lambdaOrdinal=N-- breakpoint to theNth lambdalambdaOrdinal=-1-- basic line breakpoint (no suspension in lambdas)
condition=<EXPRESSION>-- conditional breakpoints- See all capabilities in BreakpointCreator.kt
- Stepping commands are executed on suspension points. The commands are executed in the order they appear in the file.
- Basic stepping commands can be called several times:
// <COMMAND>: NRESUME,STEP_INTO,STEP_OVER,STEP_OUT
- Smart step into
// SMART_STEP_INTO_BY_INDEX: Nsteps intoNth stepping target - See all commands in SteppingInstruction.kt
- Basic stepping commands can be called several times:
Evaluation
Evaluation commands are executed in the order they appear in the file.
- Expression to evaluate is stated via
// EXPRESSION: <EXPR>command - The expected results should follow the expression
// RESULT: <RES>: <TYPE> - See AbstractIrKotlinEvaluateExpressionTest.kt for details
Adding libraries to the classpath
Use // ATTACH_LIBRARY: maven(<LIB>) to add a library to the classpath.
For example, // ATTACH_LIBRARY: maven(org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4) adds coroutines
Multifile
Use // FILE: <FILE_NAME> directive to split a file into several files. You can use Kotlin or Java files.