assertj / assertj/doc

Document AssertJ interoperability with Spock 2.4 and Groovy

Đang mở
#167 15 bình luận 3 reaction 1 người được giao Được @scordio nhận Xem trên GitHub
Ngôn ngữ chính
CSS
Star
26
Fork
32
Merge trung bình
2 ngày 9 giờ
Pull request đã merge (30 ngày)
3

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.