stelios
03/28/2024, 11:53 PMGiven("foo1") {
val files = Konsist.scopeFromProduction().files
Then("bar1") {
files.assertFalse {
it.text.contains("foo bar")
}
}
}
while the following takes 11ms:
Given("foo2") {
val files = Konsist.scopeFromProduction().files
Then("bar2") {
files.filter {
it.text.contains("foo bar")
}.assertEmpty()
}
}
Any ideas why?Vidmantas Kerbelis
03/29/2024, 6:52 AMassert
code has to be run. If you look inside it it has several checks / getTestMethodName.. and so on.
And the second one uses Kotlin collections to filter out results, running the predicate only in the scope of the "filter" function, thus slimming the results down and only then running some assertion.
In any case it shows that Konsist assertions (at least some of them) are not very optimised at this pointstelios
03/29/2024, 9:55 AMVidmantas Kerbelis
03/29/2024, 11:39 AMList<E>.assertFalse {}
into List<E> -> filter -> assertEmpty
implementation might lead to some cases failing 🤔
So, hopefully someone spends some time on optimizations in the codebase. Personally I only use it for like 5 tests, so even if each test takes 1s, it's negligible for my project.