# Debug Konsist Test

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](#evaluate-expression "mention") and [#print-to-console](#print-to-console "mention").

## Evaluate Expression Debugger Window

The [IntelliJ IDEA](https://www.jetbrains.com/idea/) / [Android Studio](https://developer.android.com/studio) provides a handy feature called [Evaluate Expressions](https://www.jetbrains.com/help/rider/Evaluating_Expressions.html#eval-expression-dialog) which is an excellent tool for debugging Konsist tests.

Create a simple test class and click on the line number to add the [breakpoint](https://www.jetbrains.com/help/idea/using-breakpoints.html):

<figure><img src="https://3782930697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYeSMx6WDKivnwWx7PdP%2Fuploads%2FajMEdUWyaGx2AOEIR3Lz%2Fimage.png?alt=media&#x26;token=3e05b66c-5e9e-43d7-bc7a-aaab0e8a0e87" alt=""><figcaption></figcaption></figure>

Debug the test:

<figure><img src="https://3782930697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYeSMx6WDKivnwWx7PdP%2Fuploads%2FwSerGcoZJaGRV58Hwbil%2Fimage.png?alt=media&#x26;token=927d7d26-93de-4898-8f6c-d3ed4f17a41f" alt=""><figcaption></figcaption></figure>

When the program stops at the breakpoint (blue line background) run `Evaluate Expression...` action...

<figure><img src="https://3782930697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYeSMx6WDKivnwWx7PdP%2Fuploads%2FKUmVT1311SmemwgnDrTo%2Fimage.png?alt=media&#x26;token=9bbc8022-da00-4793-a032-c277b6cfdb91" alt=""><figcaption></figcaption></figure>

...or press `Evaluate Expression...` button:

<figure><img src="https://3782930697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYeSMx6WDKivnwWx7PdP%2Fuploads%2FsVi8xkfsquvL3n98taMF%2Fimage.png?alt=media&#x26;token=963fae2a-8a91-476f-9438-4fcfc85fff5b" alt=""><figcaption></figcaption></figure>

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:

<figure><img src="https://3782930697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYeSMx6WDKivnwWx7PdP%2Fuploads%2Fzw6fIW0ODTil8YEWQZbL%2Fimage.png?alt=media&#x26;token=7722d32f-9fea-416f-9db7-53c420c20b39" alt=""><figcaption></figcaption></figure>

You can also display a single-class declaration to view its `name`:

```kotlin
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`:

```kotlin
koScope // KoScope
    .print()
```

Print multiple declarations:

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

Print a given attribute for each declaration:

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

Print single declaration:

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

Print list of queried declarations before and after query:

```kotlin
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:

```kotlin
koScope
    .classes() // List<KoClassDeclaration>
    .constructors // List<KoConstructorDeclaration>
    .parameters //  List<KoParameterDeclaration>
    .print()
```
