Kotlin, JUnit and TestNG, data-driven testing

Kotlin can use JUnit4 as it's test framework quite straighforwardly. Indeed this is the set up for the Kotlin tests. Moreover I can get this working for my codes. However the JUnit4 support for data-driven testing is not as good as that of TestNG. Kotlin should be able to use TestNG, but I cannot get the TestNG system to recognize the existence of the tests.

Has anyone got Kotlin working with TestNG?

I always use Kotlin with TestNG without problem

https://github.com/MarioAriasC/KotlinPrimavera

https://github.com/MarioAriasC/funKTionale

Well that is weird. With JUnit4 I did:

Test fun x() { }

but with TestNG it has to be:

[Test] fun x() { }

I think the question here may not be why didn’t TestNG work, but why did the JUnit ever work.

Thanks for pointing out my lack of brackets, I am now a much happier bunny :slight_smile:

That's interesting and looks like a bug. Can you please send us a small sample where you can reproduce this behaviour: without brackets it doesn't work, but same code with brackets does work.

I believe it has something to do with package with the name “Test”…

Weird indeed. The absence or presence of brackets is just a matter of style

Hummm… this hasn't dealt with the problem. My initial enthusiasm was squashed when I relaized I was still using JUnit4. Now I am definitely using TestNG, all the code compiles but no tests are found.

Brackets not an issue per se, other factors led me to the wrong conclusion.

The problem I have is that I cannot get the TestNG runner to recognize test methods.

Can you post a zip somewhere?

I just ru the test for my project funKTionale and is working fine with MVN and inside IntelliJ

Could you fork my repo and test in your machine?

Oh FFS, I had Guice 3.0 instead of Guice 2.0 in the path.

I now feel like a bit of a ####.

So, does it work now? :)

Thanks for having proof that it all worked as it should, it gave me confidence that it was all my fault. Which was the balance of probability anyway. Having 3 → 2 it does now all work. Now I just have to find out how to get data providers working in Kotlin.