wasyl
07/14/2020, 9:42 AMcontext
block in DescribeSpec
? @sam you mentioned (in https://kotlinlang.slack.com/archives/CT0G9SD7Z/p1593192969030900) that now nested describe blocks are allowed, but they were allowed for almost a year, since 3.4 I think. I’m asking primarily since it’s a bit surprising to see such breaking change between 4.0 and 4.1sam
07/15/2020, 3:13 AMwasyl
07/15/2020, 6:31 AM-Werror
🙂 Migration is really straightforward so I don’t mind in terms of that, only I know some of the team here enjoyed the distinction between context
and describe
since it’s how RSpec worksduplicated test name
error because our context is ignored for the purposes of the check apparentlysam
07/18/2020, 3:51 PMwasyl
07/18/2020, 4:03 PMcontext
, thus keeping DescribeSpec
more consistent with RSpec, be considered?
- would you accept a contribution to IJ plugin that somehow addresses our issue? Generally we appreciate having a separately named container to differentiate between blocks that change system context vs blocks that perform an action@TestContainer
annotation on a method that denotes opening another scope would make sense? I’ll provide more details when I have something, but in general the plugin currently doesn’t play well with neither custom alias or even extracting pieces of test functionality into methods. Since it doesn’t recognise other methods, some of our tests are all red from “duplicate test name” error, even though tests with the same names are nested differentlysam
07/18/2020, 4:06 PMwasyl
07/18/2020, 4:08 PMsam
07/18/2020, 4:08 PMwasyl
07/18/2020, 4:10 PM- test1
- test2
- test3
…
-testx
sam
07/18/2020, 4:10 PMwasyl
07/18/2020, 4:19 PMsam
07/18/2020, 4:19 PMwasyl
07/18/2020, 4:27 PMclass SomeClass(
private val dependency: AtomicInteger
) {
fun getText() = dependency.get().toString()
}
class UtilMethodExampleSpec : DescribeSpec() {
val integer = AtomicInteger()
val sut = SomeClass(integer)
init {
describe("SomeClass") {
withIntValue(4) {
describe("text") {
val result = sut.getText()
it("should be '4'") {
result shouldBe 4
}
}
withIntValue(6) {
describe("text") {
val result = sut.getText()
it("should be '6'") {
result shouldBe 6
}
}
}
}
withIntValue(5) {
describe("text") {
val result = sut.getText()
it("should be '5'") {
result shouldBe 5
}
}
}
}
}
private suspend fun DescribeScope.withIntValue(value: Int, block: suspend DescribeSpec.() -> Unit) {
context("given integer value is $value") {
integer.set(value)
block()
}
}
override fun isolationMode(): IsolationMode = IsolationMode.InstancePerLeaf
}
suspend fun DescribeScope.someStateDescription(<state values>, block: suspend DescribeSpec.() -> Unit)
to quickly open context/describe blocks which sometimes do multiple things. For this particular example it seems like no test is even executed:sam
07/18/2020, 7:02 PMprivate suspend fun DescribeScope.withIntValue(value: Int, block: suspend DescribeSpec.() -> Unit) {
context("given integer value is $value") {
integer.set(value)
block()
}
}
private suspend fun DescribeScope.withIntValue(value: Int, block: suspend DescribeScope.() -> Unit) {
context("given integer value is $value") {
integer.set(value)
block()
}
}
wasyl
07/18/2020, 10:04 PMcontext
on DescribeSpec
going back. We’re holding back on updating to recent release because context
is deprecated (and it shadows our extension) and we have -Werror
flag on 😕
I understand if it’s not priority, just then we’ll rename our extension and wait. Or maybe there’s something I can contribute to help with this?sam
08/13/2020, 6:54 PMwasyl
08/13/2020, 6:59 PMsam
08/13/2020, 7:03 PMwasyl
08/13/2020, 7:04 PMsam
08/13/2020, 7:05 PMwasyl
08/13/2020, 7:05 PMsam
08/13/2020, 7:05 PMwasyl
08/13/2020, 7:08 PM