0

Consider I have a parameterized TestNG test:

val parameters: Array<Array<Any>>
    @DataProvider
    get() {
        val parameters = arrayListOf<Array<Any>>()
        // ...
        return parameters.toTypedArray()
    }

@Test(dataProvider = "getParameters")
fun test(p1: Any, pN: Any) {
    // ...
}

How do I stop IDEA from complaining that the data provider property (parameters in our case) is unused? Annotating the property with @get:SuppressWarnings("unused") is not helpful.

Bass
  • 4,977
  • 2
  • 36
  • 82
  • Have you tried to add the `DataProvider` annotation in File | Settings | Editor | Inspections Kotlin | Redundant constructs | Unused symbol -> | **Annotations...**? – Andrey Nov 06 '18 at 11:13
  • @Andrey Thanks for the hint, but no, this didn't help. I've found a workaround though -- see my own [answer](https://stackoverflow.com/a/53171928/1343979). – Bass Nov 06 '18 at 12:30

2 Answers2

1

Add this on top of the declaration of the parameters property: @Suppress("unused")

You might need to re-compile the project to get IntelliJ to stop highlighting it as an unused property.

Yoni Gibbs
  • 6,518
  • 2
  • 24
  • 37
0

There turned out to be a workaround. Rewriting the annotation like this:

@get:DataProvider
val parameters: Array<Array<Any>>

makes IDEA treat the property as an entry point.

The corresponding ticket is KT-28031.

Bass
  • 4,977
  • 2
  • 36
  • 82