Sebastian Schuberth
11/27/2021, 2:36 PMbeforeSpec {}
/ afterSpec {}
, see https://dev.azure.com/oss-review-toolkit/ort/_build/results?buildId=6317&view=ms.vs[…]ld-test-results-tab&runId=38928&resultId=100025&paneView=debug. Is anyone else experiencing problems with Kotest 5 & Wiremock?Sebastian Schuberth
11/28/2021, 9:45 AMbeforeTest
from a TestListener
vs. a function from within the test spec are being called? I'm now seeing beforeTest
from a `TestListener`being caller after the beforeTest
overridden in a test spec, whereas I believe the order was different before. Is that expected?Sebastian Schuberth
11/28/2021, 10:06 AMbeforeTest()
in a WordSpec
also gets called for the outer WordSpecShouldContainerScope
. What can I use to just have something called for the contained actual tests, i.e. the WordSpecTerminalScope
?Rob Elliot
11/29/2021, 10:25 AM--spec
and --testpath
args to io.kotest.engine.launcher.MainKt
in the first place.Rob Elliot
11/29/2021, 10:51 AM-Dkotest.framework.classpath.scanning.config.disable=true -Dkotest.framework.classpath.scanning.autoscan.disable=true
Knocks 5 seconds off running a simple test for me.
(obviously if you’re actually relying on automatically discovered kotest config this is not such a great tip…)Sebastian Schuberth
11/29/2021, 1:17 PMshouldNotThrowAny
?sam
11/30/2021, 1:02 AMxenomachina
11/30/2021, 6:07 PMrossman
12/01/2021, 6:46 PMMervyn McCreight
12/03/2021, 12:32 PMeventually
using kotlins Duration
is still marked with @ExperimentalTime
?
I think since 1.6.0 Duration isn't experimental anymore 🤔Maxr1998
12/04/2021, 8:54 PMbeforeAny
that filters TestType.Test
, I previously declared my DI mocks in beforeEach
so that I didn't have to do that extra check. However, with Kotest 5.0, beforeEach
gets called before beforeAny
in TestExtensions, which causes my mocks to fail because Koin hasn't started yet.
I wonder if the order in TestExtensions should be changed again, as I'd expect the outer scopes to evaluate before inner scopes, thus container → any → each.Matteo Mirk
12/06/2021, 9:12 AMclass PriceSpec : StringSpec({
withData(
nameFn = { "goods=${it.goods}" },
// data rows
) { (goods, total) ->
price(goods) shouldBe total
}
"test incremental" {
...
}
})
Originally there were 2 tests, then I transformed the first into a ddt, but I lost its name wrapping the generated cases. I would like to give a name to the ddt, but If I put the withData() declaration inside a string block it’ll fail at runtime, and if I wrap it with a context(“name”) as shown in the docs, only the second test will be executed. What am I doing wrong?Sebastian Schuberth
12/06/2021, 4:57 PMPhilipp Mayer
12/07/2021, 5:01 PMclass SomeE2ETest: E2ETestEnvironment { ... }
where E2ETestEnvironment is a class (annotated with @SpringBootTest
) that holds common project config, e.g. a preconfigured http client to post something to the api.
Converting this test simply to a Kotest test will not work as we can’t do the following:
class SomeE2EKotest: E2ETestEnvironment(), BehaviorSpec({ ... })
because only one class may appear in a super type list.
Long story short: I unfortunately couldn’t find any resource about how to do this with Kotest. Our main scenario is that we probably (currently) only translate the E2E Tests, so I’d like to find a way to access the E2ETestEnvironment
from both JUnit tests and Kotest Tests.
Thanks in advance!Peter
12/09/2021, 6:33 PMsam
12/10/2021, 12:15 PMJames Eschner
12/10/2021, 8:39 PM5.0.2
and am set the system property kotest.framework.dump.config=true
in my gradle.properties
but I am not seeing anything in the logs like I used to (prior to the jump to 5+).
Is there another way to check the configuration at runtime?
* Not a contribution *Niko
12/17/2021, 8:06 AM./gradlew test
.
Currently, I have a root project with multiple subprojects (modules), and I'm applying some conventions (like applying Kotest) to all the subprojects using a Gradle plugin. I'm wondering, if this setup has somehow screwed up the discovery
(more in thread)LeoColman
12/17/2021, 3:08 PMmyAlgo shouldRunIn logOfN()
Asq
12/20/2021, 11:34 PMshouldBe
is a List
, and the rhs is a home-grown Iterable
. This happens in IterablEq.kt
(kotest 5.0.3) as
fun isValidIterable(it: Any): Boolean {
return when (it) {
is List<*>, is Set<*>, is Array<*>, is Collection<*> -> true
else -> false
}
}
Could someone please help me understand why a custom implementation of Iterable
should not be considered a valid iterable for the purposes of kotest
?phil-t
12/21/2021, 10:56 AMtestString shouldHaveMinLength 1
But it doesn’t work for a `Int?`:
testInt shouldBeGreaterThan 0
The error is - Infix call corresponds to a dot-qualified call 'testInt.shouldBeGreaterThan(0)' which is not allowed on a nullable receiver 'testInt'. Use '?.'-qualified call instead
So I can get around it by doing this:
testInt?.shouldBeGreaterThan(0)
Is this a limitation of Kotest and is there a better way I can handle this?Rob Elliot
12/21/2021, 7:00 PMinternal class AuctionSniperEndToEndContainerTest : StringSpec({
tags(Docker)
listener(openfireTestContainer(Paths.get("../docker-openfire")).perSpec())
...
}
Alexandre Brown
12/22/2021, 7:41 PMMockkAnnotations.init(this)
inside the beforeEach
block and I use lateinit var
on my mocks. Is this bad or is this the recommended way?
I find that using val
is not always possible as sometimes you have some expectations to setup first.
class MyClassTest : StringSpec() {
private lateinit var myClass: MyInterface
@RelaxedMockK
private lateinit var myMock1: MockableThing1
@RelaxedMockK
private lateinit var myMock2: MockableThing2
init {
beforeEach {
MockKAnnotations.init(this)
myClass = MyClass(
myMock1,
myMock2
)
}
}
...
Javier
12/24/2021, 5:05 PMLukasz Kalnik
12/28/2021, 6:14 PMSuccess(Either.Left(IOError(cause=com.google.gson.stream.MalformedJsonException)))
I want to assert certain things:
• that the contents of Success
is of type Left
• that the contents of Left
is of type IOError
• that the cause
is of type MalformedJsonException
Srki Rakic
01/08/2022, 2:33 PMLukasz Kalnik
01/11/2022, 1:10 PMclass NetworkEitherCallAdapterTest : StringSpec({
private lateinit var server: MockWebServer
private lateinit var service: CallErrorTestClient
beforeAny {
server = MockWebServer()
server.start()
service = Retrofit.Builder()
.baseUrl(server.url("/"))
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(EitherCallAdapterFactory.create())
.build()
.create(CallErrorTestClient::class.java)
}
afterAny { server.shutdown() }
"should return ResponseMock for 200 with valid JSON" {
server.enqueue(MockResponse().setBody("""{"response":"Arrow rocks"}"""))
val body = service.getEither()
body shouldBe ResponseMock("Arrow rocks").right()
}
// More tests...
I want to run the test class 3 times with different service
instances (which will use different ConverterFactory
each). What is the most readable way to achieve it? I don't want to parameterize every test, I want to parameterize the whole class and repeat it.Dhaval Gondaliya
01/12/2022, 6:00 AMJames Eschner
01/12/2022, 10:05 PMArb
automagically using Arb.bind
is that I’m not getting any null support. For example, if I have the following data class:
data class Foo(
val myInt: Int?
)
and I generate an arb like so:
val fooArb = Arb.bind<Foo>()
I have never encountered a generated value with myInt == null
. Is this expected? Is there a way to get this behavior?
* Not a contribution*phldavies
01/13/2022, 12:34 PMphldavies
01/13/2022, 12:34 PMwarnings.shouldHaveSingleElementSatisfying {
message shouldContainIgnoringCase "cheese"
code shouldBeGreaterThan 100
}
sam
01/13/2022, 12:43 PMphldavies
01/13/2022, 12:44 PM