assertj / assertj/doc

Document AssertJ interoperability with Spock 2.4 and Groovy

オープン
#167 コメント 15 件 リアクション 3 件 担当者 1 名 @scordio が担当を希望しています GitHub で見る
主要言語
CSS
スター
26
フォーク
32
平均マージ
2日 9時間
マージ済み PR(30日)
3

説明

**Describe the bug**
The feature from assertj/assertj#2520 seems to be incompatible with using the `StringAssert`from 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

```groovy
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')
}
}
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。