Michael Strasser
11/18/2021, 8:32 AMwithData
and DescribeSpec
but I can’t get the tests to be named as I expect.
Given a function fun messageMap(id: String): Map<String, Message>
that returns 3 different messages, if I use:
describe("adds messages") {
val id = randomId()
it("sets ID from message") {
withData(messageMap(id)) { message ->
Builder.newInstance().addMessage(message).getId() shouldBe id
}
}
}
The test runs once with title “sets ID from message”. But if I use:
describe("adds messages") {
val id = randomId()
withData(messageMap(id)) { message ->
it("sets ID from message") {
Builder.newInstance().addMessage(message).getId() shouldBe id
}
}
}
The test runs 3 times with titles:
sets ID from message
(1) sets ID from message
(2) sets ID from message
I expected from the docs that the string keys for the map would be used as test names.
I am using Kotest 4.6.3.BorzdeG
11/20/2021, 11:18 AMdescribe("adds messages") {
it("sets ID from message") {
val id = randomId()
withData(messageMap(id)) { message ->
Builder.newInstance().addMessage(message).getId() shouldBe id
}
}
}
sam
11/20/2021, 4:09 PMit
). Otherwise the output doesn't work properly on gradle.BorzdeG
11/20/2021, 4:11 PMsam
11/20/2021, 4:11 PMsam
11/20/2021, 4:11 PMsam
11/20/2021, 4:12 PMsam
11/20/2021, 4:14 PMMichael Strasser
11/21/2021, 11:39 AMdescribe
but without specifying it
. For example:
describe("adds messages") {
describe("sets ID from message") {
withData(messageMap(randomId())) { message ->
Builder.newInstance().addMessage(message).getId() shouldBe id
}
}
}
Michael Strasser
11/21/2021, 12:16 PMsam
11/21/2021, 2:27 PMMichael Strasser
11/21/2021, 10:08 PMit
run, but those generated by withData
do not. By contrast, the Kotest plugin runs all of them.
In one test file, Gradle and Kotest both report 9 tests (the number of `it`s) but Kotest runs the 92 extra withData
tests, while Gradle does not (as far as I can tell).
I ran a small experiment with that file. I caused a test to fail by modifying a value returned by the messageMap()
function.
• Kotest reported details of the failing test, as expected.
• Gradle reported failure of the parent describe
block but with no details.
I hope this helps. (Sorry, I can’t share actual client code with you.)sam
11/21/2021, 10:09 PMsam
11/21/2021, 10:09 PMMichael Strasser
11/21/2021, 10:22 PMmessageMap()
to break tests, both Gradle and Kotest correctly report which tests failed.sam
11/21/2021, 10:22 PMMichael Strasser
11/21/2021, 10:23 PMsam
11/21/2021, 10:23 PMsam
11/21/2021, 10:23 PMit
as that will be disallowed latersam
11/21/2021, 10:23 PMMichael Strasser
11/21/2021, 10:25 PM