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

Chưa có ai nhận issue này.

Đánh giá

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

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.

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?

Ngôn ngữ chính
Java
Star
72
Fork
47
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của assertj/assertj-generator

Tất cả issue của assertj/assertj-generator

Issue tương tự

Thêm issue về Java

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.