https://kotlinlang.org logo
Title
p

Paul Woitaschek

06/07/2022, 1:36 PM
Is there a way to let ksp generate tests? I want to generate a test based on my main source set.
👀 1
j

Jiaxiang

06/07/2022, 5:11 PM
it depends on the format of tests you want to generate.. if you need to parse into function body to generate tests then it is not possible, so it really depends on your use case, I can think of cases where KSP can do this, like the api tests in KSP itself can be done by KSP..
p

Paul Woitaschek

06/07/2022, 5:28 PM
Just any test. I only need to inspect function signatures. If I define KSP the tests end up in my main source sets. If I define testKsp then the processor does not pick up any symbols - actually it doesn't run at all
j

Jiaxiang

06/07/2022, 5:30 PM
I see, your requirement here is actually generating sources for another source set in another task.. IIRC there was similar ask before. might need more work on Gradle to achieve this. The first idea I have is to add the generated folder into source sets of test task, will that work?
p

Paul Woitaschek

06/07/2022, 5:31 PM
No then it won't run due to duped classes
j

Jiaxiang

06/07/2022, 5:32 PM
might need an option for gradle to not add generated folders into main source set, I am not sure if that is doable, I will take a look later.
p

Paul Woitaschek

06/07/2022, 5:33 PM
That would be great 🤞
Is there any workaround you could think of? I have a pretty cool idea for a Library
j

Jiaxiang

06/09/2022, 12:09 AM
I can’t think of a workaround at this moment. You might be able to do that with some gradle trick like writing a task to move files, but doesn’t look like a good practice to me.