codewars / runner

Issue tracker for Code Runner
34 stars 8 forks source link

Spock data-driven tests produce invalid output #302

Open hobovsky opened 6 months ago

hobovsky commented 6 months ago

Describe the bug While using Spock framework in Groovy translations, data-driven tests with @Unroll-ed titles produce unclosed test group what results in wrong output:

image

To Reproduce Run following test suite in Groovy kumite:

import spock.lang.*

class SubmissionTests extends Specification {
  def "Fixed tests"(int n, int exp) {
    expect:
      Kata.nextHigher(n) == exp
    where:
               n | exp
             128 | 256
               1 | 2
            1022 | 1279
             127 | 191
         1253343 | 1253359
      0x0C000000 | 0x10000001
      0x2FFFFFFF | 0x37FFFFFF
  }
}

class RandomTests extends Specification {
  @Unroll
  def "nextHigher(#n) should be #exp"() {
    expect:
      Kata.nextHigher(n) == exp
    where:
      [n, exp] << [
                   [        128, 256],
                   [          1, 2],
                   [       1022, 1279],
                   [        127, 191],
                   [    1253343, 1253359],
                   [ 0x0C000000, 0x10000001],
                   [ 0x2FFFFFFF, 0x37FFFFFF]
                ]
  }
}

Additional context One alternative would be to use JUnit 5, but Groovy setup is missing packages necessary to create parametrized tests (see #301).