test is simple ```class MathKtTest : FreeSpec({ ...
# kotest
s
test is simple
Copy code
class MathKtTest : FreeSpec({
    data class Points(
        val apr: String,
        val term: Int
    )
    "calculate discount factor" - { 
        forAll(
            row("1", 12)
        ) { (apr, term) ->
            val D = calculateDiscountFactor(BigDecimal(apr), term)
            assertEquals(BigDecimal("75.6813"), D)
        }
    }
})
method is a top level method
Copy code
fun calculateDiscountFactor(apr: BigDecimal, term: Int) :BigDecimal{
    val r = apr
    val n = 12 * term
    val denominator = { ((BigDecimal.ONE + apr).pow(n)) - BigDecimal.ONE }
    val numerator = { r * (BigDecimal.ONE + r).pow(n) }
    return numerator() / denominator()
}
kotest version 4.4.1, plugin version
1.1.30-IC-2020.3
kotlin version 1.3.72
w
That’s pretty old Kotlin version, isn’t it?
Is there any chance you can bump it to anything more recent?
s
yes it is. We're unable to update right now due to the framework we're using (Quarkus and Kogito)
👀 1
we have a dev working on it right this moment though.
so maybe he'll get it working in the next week or so.
But we already have kotest tests running just fine in this project. First time this has popped up.
👍 1
w
This looks like some incompatibility between Kotest compiled against Kotlin 1.4 and you using Kotlin 1.3. Is there any older Kotest version compiled still against Kotlin 1.3 but without API changes perhaps?
s
hm. I hadn't updated kotest until after getting this issue. I am absolutely swamped right now though so I can't really debug into this. I posted here hoping that it was a known issue. If it isn't I'll wait to see if my coworker can get us onto 1.4 (I have tried several times and failed, he knows Quarkus better than I) and then I'll see if that fixes it.
👍 1
w
I tried your test on 4.4.0 and 4.4.1 and it works for me on Kotlin 1.4.31 (test fails though 😛). I also checked with using
Points
class directly
s
ok. thanks for the confirmation.
w
So yeah, you can just do
listOf(…).forEach { /* test */ }
in the time being I guess
s
oh I'll try that.
s
Kotest 4.4.0 went to Kotlin 1.4. I try to make this clear in the changelogs but if we've missed something or could do a better job in places please let me know.
👍🏽 1