TestNG, Spock, and Spek

TestNG has DataProviders, Spock has where clauses, but from what I can see Spek only allows for linear tests, having no capability for data-driven testing. Or am I just missing something?

You have givenData

Here’s an example

https://github.com/MehdiK/Humanizer.jvm/blob/master/test/main/kotlin/org/humanizer/jvm/tests/PluralizeTests.kt

I failed to read the documents well enough. I suspected as much!

So now the question is how to have two data sets and create a Cartesian product of them and use the result with givenData. I don’t suppose you have a ready made example of that as well?

BTW Spock works very well testing Kotlin code. But not very Kotlinicly I guess.

Nothing built-in but it's basically a pair. So as long as you give it the pair it should be good, but this means you'd have to do the cartesan product yourself unfortunately. However, that's a good addition so if you're up for a PR :)   

Am playing. Current result is not entirely great as I am using arrays as n-tuples.

My current real issue is that I am failing to find the way Spek allows to check for an exception being thrown. Assertion.kt appears to have no shouldThrow.

You should be able to still use any of the Kotlin assertions that ship, including failsWith. In any case, I've just added it and pushed. If all goes well, it should be available in a bit.   

Ah, indeed kotlin.test.failsWith. I just never thought of using those, I wasn't thinking straight :-(

Using it in the interim and getting successful tests. Sadly though the Run output gives things like:

  Object;@73a28541 (given [Ljava.lang

as the name of the test, which isn’t really that helpful. I also note that I can only export the run output as HTML or XML, not just text.

This is with what test? Do you have a sample?

The output is actually extensible. Writing a text output should be failry straightforward.

I have sent you an email with a zipfile.

I will be putting this all on GitHub soon