Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Spock data-driven tests produce invalid output #302

Open
hobovsky opened this issue May 15, 2024 · 0 comments
Open

Spock data-driven tests produce invalid output #302

hobovsky opened this issue May 15, 2024 · 0 comments

Comments

@hobovsky
Copy link

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).

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants