https://kotlinlang.org logo
#strikt
Title
r

robfletcher

07/15/2020, 8:00 PM
That looks amazing
🤗 1
m

Michael

07/15/2020, 8:01 PM
well...not yet. But I'll put in some effort. 🙂 thanks!
r

robfletcher

07/15/2020, 8:02 PM
It’s a great idea. Had certainly crossed my mind but I’d never put any serious thought into how it could be done.
m

Michael

07/15/2020, 8:11 PM
It's pretty gross tbh and I could not have done it without squareup's libraries around kotlin metadata.
kapt
is straightforward, but it does not give you the necessary type information to generate assertions. Will have to do more testing before expanding from data classes to other types (classes, sealed classes, inheritance,...)
r

robfletcher

07/15/2020, 8:17 PM
Yeah, I’ve tried to do some stuff inferring Open API schemas from Kotlin types and it’s not beautiful.
c

christophsturm

07/16/2020, 10:52 AM
is it possible to do this without annotating the data class? I think tests should not need chages to tested classes.
m

Michael

07/16/2020, 10:59 AM
AFAIK it is possible to run an annotation processor without annotations, but I will have to verify. You will then have to configure the classes you want Assertions to be generated for in the gradle plugin. Could look something like this:
build.gradle
Copy code
strikt {
     sources += com.acme.MyClass //fqcn

}
Though I have to say that adding one annotation with source retention (annotation isn't stored in binary output) to the main classpath should not really matter...
🤔 I think I can get rid of the annotation and kapt altogether and just use a gradle plugin. Should simplify things a lot for users. Thanks for the brain stimulus Christoph.
c

christophsturm

07/16/2020, 11:43 AM
yay!
r

robfletcher

07/16/2020, 4:15 PM
I think that’s a good idea. It feels like it ought to be possible to find classes by package scanning.
2 Views