Konsist
GitHubSlack (kotlinlang)Twitter
  • 🚀GETTING STARTED
    • What is Konsist?
    • Getting Started
      • Add Konsist Dependency
      • Create First Konsist Test - Declaration Check
      • Create Secound Konsist Test - Architectural Check
    • Articles & Videos
  • ✅WRITING TESTS
    • Create The Scope
    • Declaration Filtering
    • Declaration Assertion
    • Architecture Assertion
    • Suppress Konsist Test
  • ✏️VERYFYING CODEBASE
    • Verify Classes
    • Verify Interfaces
    • Verify Functions
    • Verify Properties
    • Verify Generics
    • Verify Source Declarations
  • 📗FEATURES
    • Add Konsist Existing To Project (Baseline)
    • Debug Konsist Test
    • Declaration
    • Declaration Vs Property
    • Compiler Type Inference
    • Package Wildcard
    • Declaration References
    • Indirect Parents
    • Kotest Support
  • 🔍INSPIRATION
    • Starter Projects
    • Snippets
      • General Snippets
      • Android Snippets
      • Spring Snippets
      • Test Snippets
      • JUnit Snippets
      • Kotest Snippets
      • Architecture Snippets
      • Clean Architecture Snippets
      • Kotlin Serialization Snippets
      • Library Snippets
      • Generic Types Snippets
  • 🎓ADVANCED
    • Isolate Konsist Tests
    • Enable Full Command Line Logging
    • Dynamic Konsist Tests
      • Explicit Test Names
    • When Konsist API Is Not Enough
    • Additional JUnit5 Setup
    • Why There Are No Pre-defined Rules?
    • Konsist Snapshots
  • ❓HELP
    • Getting Help
    • Known Issues
      • java.lang.OutOfMemoryError: Java heap space
    • Compatibility
  • ℹ️OTHER
    • Changelog
    • Project Status
    • Contributing
    • Contributors
    • Assets And Logos
    • Open Source Licenses
    • Sponsor Konsist
Powered by GitBook
On this page
  • Evaluate Expression Debugger Window
  • Print To Console
Edit on GitHub
Export as PDF
  1. FEATURES

Debug Konsist Test

Understand whats going on

PreviousAdd Konsist Existing To Project (Baseline)NextDeclaration

Last updated 6 months ago

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 / provides a handy feature called which is an excellent tool for debugging Konsist tests.

Create a simple test class and click on the line number to add the :

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:

koScope
    .classes()
    .first()
    .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:

koScope // KoScope
    .print()

Print multiple declarations:

koScope
    .classes() // List<KoClassDeclaration>
    .print()

Print a given attribute for each declaration:

koScope
    .classes() // List<KoClassDeclaration>
    .print { it.fullyQualifiedName }

Print single declaration:

koScope
    .classes() // List<KoClassDeclaration>
    .first() // KoClassDeclaration
    .print()

Print list of queried declarations before and after query:

koScope
    .classes() // List<KoClassDeclaration>
    .print(prefix = "Before") // or .print(prefix = "Before") { it.name }
    .withSomeAnnotations("Logger")
    .print(prefix = "After") // or .print(prefix = "After") { it.name }

Print nested declarations:

koScope
    .classes() // List<KoClassDeclaration>
    .constructors // List<KoConstructorDeclaration>
    .parameters //  List<KoParameterDeclaration>
    .print()
📗
IntelliJ IDEA
Android Studio
Evaluate Expressions
breakpoint