assertj / assertj/assertj-generator

Should assertions for properties of the superclass(es) be generated?

Đang mở
#91 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
72
Fork
47
Merge trung bình
1 ngày 16 giờ
Pull request đã merge (30 ngày)
2

Mô tả

Consider this class:

```
import org.apache.http.client.HttpResponseException;

public class SomeErrorException extends HttpResponseException {
private SomeError error;

public SomeErrorException(int statusCode, String reason, SomeError error) {
super(statusCode, reason);
this.error = error;
}

public SomeError getError() {
return error;
}
}
```

It would be nice to be able to test `SomeErrorException` objects like this:

```
assertThat(exception).hasStatusCode(500)
.hasMessage("Internal Server Error")
.hasError(error)
```

However, `hasStatusCode` and `hasMessage` are not generated because they are defined in superclasses. If I include `HttpResponseException` in the generator configuration (in `pom.xml`), the `hasStatusCode` appear, but of course `hasMessage` is only present if I also include the whole hierarchy (four classes!) up to `Throwable`. Also, `org.assertj.core.api.Assertions.assertThat(Throwable)` already exists, so I cannot make my assertions a subclass (but problem with this idea are already discussed in the documentation).

Does it make sense to make it easier to include assertions for properties of superclasses?

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

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách đọc cấu hình generator trong pom.xml và tài liệu được tham chiếu trong issue, sau đó kiểm tra cách các assertion của superclass được đưa vào. Theo dõi hệ thống phân cấp ví dụ từ SomeErrorException qua HttpResponseException đến Throwable và xem xét giới hạn hiện có của Assertions.assertThat(Throwable). Được xem là hoàn thành khi đã quyết định và ghi lại một phương án để tạo assertion cho các thuộc tính được kế thừa mà không xung đột với các assertion hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
testing, tooling
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

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.