Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@
A reflection test harness for [KSP](https://kotlinlang.org/docs/ksp-overview.html); use reflection to seamlessly test your KSP generators.


## Comparison with kotlin-compile-testing

[kotlin-compile-testing](https://github.com/ZacSweers/kotlin-compile-testing) and `ksp-reflection-testing` solve different problems and are best understood as complementary rather than competing tools.

**kotlin-compile-testing** is an **integration testing** library. It spins up an in-process Kotlin compiler, feeds it real source files, runs your KSP processor against them, and lets you assert on the generated output. This is the right tool when you want to verify end-to-end behavior — that your processor produces the correct files given real source input.

**ksp-reflection-testing** is a **unit testing** library. Instead of invoking the compiler, it uses Kotlin reflection to construct KSP symbol objects (`KSClassDeclaration`, `KSFunctionDeclaration`, etc.) directly from existing classes at runtime. This lets you test the logic inside your processor in isolation — fast, without a compilation step, and with no need to write source strings in test files.

| | ksp-reflection-testing | kotlin-compile-testing |
|---|---|---|
| **Test type** | Unit | Integration |
| **Speed** | Fast (no compilation) | Slower (full compiler invocation) |
| **Input** | Existing Kotlin classes via reflection | Source files as strings |
| **Output** | Assert on processor logic directly | Assert on generated files/classes |
| **Best for** | Testing processor logic in isolation | Testing end-to-end code generation |

Use `ksp-reflection-testing` when you want fast, focused unit tests for the internal logic of your KSP processor. Use `kotlin-compile-testing` when you want to verify the full pipeline — that your processor generates the right output from real source input. For thorough coverage, use both.

## Getting Started

You can check out [our tests](https://github.com/Faire/ksp-reflection-testing/blob/main/ksp-test-fixtures/src/test/kotlin/com/faire/ksp/test/ReflectionEquivalenceTest.kt) to see how to use the library (more instructions to come soon!).
Expand Down