Debug Konsist Test
Understand whats going on
To gain insight into the inner workings of the Konsist test, examine the data provided by the Konsist API.
Two primary tools can help you comprehend the inner workings of the Konsist API are #evaluate-expression and Print To Console.
Evaluate Expression Debugger Window
The IntelliJ IDEA / Android Studio provides a handy feature called Evaluate Expressions which is an excellent tool for debugging Konsist tests.
Create a simple test class and click on the line number to add the breakpoint:
Debug the test:
When the program stops at the breakpoint (blue line background) run Evaluate Expression...
action...
...or press Evaluate Expression...
button:
In the Evaluate
window enter the code and click the Evaluate
the button. For example, you can list all of the classes present in the scope to get the class names:
You can also display a single-class declaration to view its name
:
Print To Console
Konsist provides a flexible API that allows to output of the specified data as console logs. Scopes, lists of declarations, and single declarations can all be printed.
Print a list of files from KoScope
:
Print multiple declarations:
Print a given attribute for each declaration:
Print single declaration:
Print list of queried declarations before and after query:
Print nested declarations:
Last updated