Areo
Areo

Reputation: 938

Create Kotlin annotation from Java @Test TestNG annotation

I am using Java TestNG annotation:

@Test(groups = ['integration'])

And I would like to create Kotlin annotation like:

@IntegrationTest

Is it doable ?

Upvotes: 1

Views: 348

Answers (1)

Ilya
Ilya

Reputation: 23115

No, as of now Kotlin language doesn't have builtin tools that enable such use case.

You can resort to the annotation processing technique: write an annotation processor that replaces your custom @IntegrationTest with @Test from TestNG.

One drawback of annotation processing is that a processor is a black box to the tooling. For example, IDE won't treat the methods annotated with @IntegrationTest as tests because it doesn't know that they are going to be post-processed later.

Also annotation processing is a JVM-specific tool, so it isn't supported on other platforms.

Upvotes: 2

Related Questions