Provide means to obtain current test case name and current section name

Đang mở
#2,859 4 bình luận 8 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
42/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
cpp
Lĩnh vực
testing-qa

Hướng nghiên cứu

Bắt đầu bằng việc xem xét đường dẫn đã lỗi thời Catch::getResultCapture().getCurrentTestName() và phần triển khai RunContext được đề xuất sử dụng các trình theo dõi section đang hoạt động. Theo dõi cách tên test và section hiện tại được biểu diễn, sau đó xác định cách truy cập ổn định cho tên test và tên section, có hỗ trợ phân cấp nếu khả thi. Được coi là hoàn thành khi các tên được yêu cầu có thể sử dụng mà không phụ thuộc vào các API đã lỗi thời và được kiểm thử bằng các test phù hợp.

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

Mô tả

Description

I propose the following changes:

  • Add a feature to get the current test case's name
  • Add a feature to get the current section's name
  • Optionally: Add a feature to get the current section's hierarchy of names

These changes are useful if additional data for testing is loaded from or written to a filesystem. Directories and filenames could depend on the current section and thereby reduce duplication.

Additional context

In the past sometimes requests for these features were made but none ever reached a stable upstream (or non-deprecated) state. Especially the issue https://github.com/catchorg/Catch2/issues/510 (by @mlogan) contained a request for such features. However, it was resolved since workarounds were available.

Feature to get the current section's hierarchy of names

In the issue https://github.com/catchorg/Catch2/issues/510 @jgm-radez suggested (and @isidore supported) the following approach to obtain the current section's hierarchy of names:

virtual std::vector<std::string> getCurrentSectionNames() const {
            std::vector<std::string> retval;
            for(std::vector<ITracker*>::const_iterator iter=m_activeSections.begin(); iter!=m_activeSections.end(); ++iter)
                    retval.push_back((*iter)->nameAndLocation().name);
            return retval;
}

(Assumption: implemented in RunContext)

Feature to get the current test case's name

This feature is currently available in Catch2 but it was marked as deprecated in commit 57c346a by @philsquared and I could not find a reason for it. Why was this done?

Catch::getResultCapture().getCurrentTestName();

Ngôn ngữ chính
C++
Star
21.6k
Fork
3.4k
Merge trung bình
3 ngày 12 giờ
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

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 catchorg/Catch2

Tất cả issue của catchorg/Catch2

Issue tương tự

Thêm issue về C++

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.