Skip to content

Faire/ksp-reflection-testing

Repository files navigation

ksp-reflection-testing

A reflection test harness for KSP; use reflection to seamlessly test your KSP generators.

Comparison with kotlin-compile-testing

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 to see how to use the library (more instructions to come soon!).

Contributing

If you like ksp-reflection-testing, give us a star to help the project!

Have you found a bug or have a suggestion? Open an issue and we will take a look at it as soon as possible.

Do you want to contribute with a PR? Make sure to read our Contributing Guide!

About

Reflection test harness for KSP

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages