zak.taccardi
09/14/2024, 3:14 PMinternal class MyTest {
@Jira("abc-1") @Test fun testFunction1() { .. }
@Jira("abc-2") @Test fun testFunction2() { .. }
}
I need to generate a .yaml
file, that identifies all the JIRA IDs, and associates each one with the test class name and method, like so:
- jira_id: abc-1
test_cases:
-MyTest/testFunction1
- jira_id: abc-2
test_cases:
-MyTest/testFunction2
What tooling should I use to read the test annotations? A Kotlin compiler plugin? KSP?
Note: I’m not generating any Kotlin code from this, so I technically don’t need to block normal compilation in any way for this use caseChrimaeon
09/14/2024, 5:54 PMzak.taccardi
09/14/2024, 5:55 PMChrimaeon
09/14/2024, 5:56 PMzak.taccardi
09/14/2024, 5:57 PMall the JIRA IDs, and associates each one with the test class name and methodI need the class/function information for all functions annotated with
@Jira
, then the values inside that annotation. and from that, I can generate the .yaml
fileChrimaeon
09/14/2024, 5:58 PMzak.taccardi
09/14/2024, 6:01 PMsrc/test
and src/androidTest
)Chrimaeon
09/14/2024, 6:01 PMzak.taccardi
09/14/2024, 6:10 PMChrimaeon
09/14/2024, 6:14 PMbuild/reports
folder).
your new task then just adds a dependency (dependsOn
in gradle language) on test
, testDebugUnitTest
, etc., so when you run your task the test tasks are executed, and consumes the file.zak.taccardi
09/14/2024, 6:18 PMdon’t these test tasks already have a runner though? I don’t want to mess with them, and don’t want to actually execute tests to achieve my goal,test
testDebugUnitTest
Chrimaeon
09/14/2024, 6:24 PMAndroidJUnit4
Chrimaeon
09/14/2024, 6:32 PMephemient
09/14/2024, 8:34 PMephemient
09/14/2024, 8:45 PMkotlin {
jvm {
compilations.getByName("test") {
tasks.register<JavaExec>("listTestCases") {
classpath(runtimeDependencyFiles, output)
mainClass = "com.example.test.ListTestCases"
and then write src/jvmTest/kotlin/com/example/test/ListTestCases.kt
like any normal main()
entry pointzak.taccardi
09/14/2024, 8:47 PMsrc/androidTest
code as well.
But JavaExec
does sound nice in that it's guaranteed not to mess with any normal compilationephemient
09/14/2024, 8:49 PMephemient
09/14/2024, 8:52 PMephemient
09/14/2024, 8:53 PMzak.taccardi
09/14/2024, 9:00 PM