Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Spock datatable just accepting integers in Speck inputs #1038

Open
jpsalvadorm63 opened this issue Oct 4, 2019 · 2 comments

Comments

@jpsalvadorm63
Copy link

commented Oct 4, 2019

Spock datatable just accepting integers in Speck inputs

Hi, I'm working in migrating a large application from Grails 3.3 to Grails 4.

On of the issues we got is related to Spock, the functionality we used in Grails 3.39 seems to be missing: whe using a datatable to represent the specs, the column for the inputs, seems to be accepting jus integers values

In the below code just the first line of the specks is passing the text. No the next two, as the spock is transforming to integer befor passing it to Math.round(value)

import spock.lang.*

@Unroll
 void 'test to demostrate Spock is just accepting integer in datatable column value'() {
   expect:
       Math.round(value) == result   
   where:
   value     | result
   1234      | 1234
   4321.56d  | 4322d
   1111.56f  | 1112d
 }

I was noty getting this issue in version 3.3 of Grails.

Thanks in advance for attend this issue

Juan

UPDATE:

The change of behavior described, actually occurs when the test based on datatable is preceded by a test that includes throwing an excetion

WORK AROUND:

Move the test that includes the exception throwing to be the last test.

@virtualdogbert

This comment has been minimized.

Copy link

commented Oct 4, 2019

This would be going from Spock 1.1 to 1.2.

@Vampire

This comment has been minimized.

Copy link
Contributor

commented Oct 7, 2019

Can you provide an MCVE?
And how is this related to Grails?

This works perfectly fine:

    def 'failing test'() {
        when:
            throw new RuntimeException()
        
        then:
            thrown(RuntimeException)
    }

    @Unroll
    def 'data driven test'() {
        expect:
            Math.round(value) == result

        where:
            value    | result
            1234     | 1234
            4321.56d | 4322d
            1111.56f | 1112d
    }

While it is questionable whether the result should contain double values to compare to the long or int result of the round call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.