Document AssertJ interoperability with Spock 2.4 and Groovy

Aperta
#167 15 commenti 3 reazioni 1 assegnatario Vedi su GitHub

@scordio ci sta già lavorando.

Dal 1/3/2024.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Describe the bug
The feature from assertj/assertj#2520 seems to be incompatible with using the StringAssertfrom assertj-core in a Groovy and Spock setup.

The then block in a spock test feature wraps any assertion code line with an groovy powerassert assert under the hood expecting the actual assertion expression to be evaluated as a boolean value. In Groovy there is the org.codehaus.groovy.runtime.DefaultGroovyMethods#asBoolean(java.lang.Object) method that Spock is calling. Due to the changes made to the AbstractStringAssert class this method is inaccessible and returns a BooleanAssert instead.

  • assertj core version: 3.25.3
  • java version: 17
  • groovy version: 4.0.18
  • test framework version: Spock 2.3-groovy-4.0
  • os (if relevant):

Test case reproducing the bug

Add a test case showing the bug that we can run

import spock.lang.Specification

import static org.assertj.core.api.Assertions.assertThat

class DemoSpec extends Specification {
    def 'assert some integer'() {
        when:
        def someInteger = 10

        then:
        assertThat(someInteger).isEqualTo(10)
    }

    def 'assert some string'() {
        when:
        def someString = 'some string'

        then:
        assertThat(someString).isEqualTo('some string')
    }
}
Lingua principale
CSS
Stelle
26
Fork
32
Merge medio
1g 19h
PR unite (30g)
4

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di assertj/doc

Tutte le issue di assertj/doc

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.