Skip to content

Commit 73c451f

Browse files
authored
docs: highlight the different uses cases between this library and the compile testing library (#6)
1 parent 6b6899a commit 73c451f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
A reflection test harness for [KSP](https://kotlinlang.org/docs/ksp-overview.html); use reflection to seamlessly test your KSP generators.
44

55

6+
## Comparison with kotlin-compile-testing
7+
8+
[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.
9+
10+
**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.
11+
12+
**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.
13+
14+
| | ksp-reflection-testing | kotlin-compile-testing |
15+
|---|---|---|
16+
| **Test type** | Unit | Integration |
17+
| **Speed** | Fast (no compilation) | Slower (full compiler invocation) |
18+
| **Input** | Existing Kotlin classes via reflection | Source files as strings |
19+
| **Output** | Assert on processor logic directly | Assert on generated files/classes |
20+
| **Best for** | Testing processor logic in isolation | Testing end-to-end code generation |
21+
22+
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.
23+
624
## Getting Started
725

826
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!).

0 commit comments

Comments
 (0)