Issue with Name format assignment in 3.12

Đang mở
#324 10 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
documentation, testing

Hướng nghiên cứu

Bắt đầu với tài liệu về SetName và TestCaseData cùng bản tái hiện được cung cấp với DemoTestClass; so sánh hành vi định dạng được ghi trong tài liệu với tên các bài kiểm thử quan sát được trong NUnit và các trình chạy kiểm thử được nêu tên. Công việc được xem là hoàn tất khi xác định được tài liệu hay hành vi là không chính xác và cập nhật tài liệu liên quan để mô tả chính xác hành vi của {m} và ảnh hưởng của các tên trùng lặp.

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

Mô tả

According to the documentation for the "SetName" property:
"The SetName property of TestCaseData allow setting the format string for the individual test case. So long as no format specifiers are used in the name, there will be no change in how this works."

With a name being assigned as "String name", we would expect no hierarchical change in the name of the test. However, the {m} section is being removed regardless. We can manually add the {m} format specifier in each case, however this conflicts with provided documentation.

There is an additional issue can resulted as part of this problem, when test case data is shared across multiple tests. If multiple items end up sharing the same name (due to the {m} being missing) it causes the remaining test information to become statically listed within MSTest, and several other Test Runners (including the Resharper test runner).

Code to replicate is included:

    [TestFixture]
    public class DemoTestClass
    {
        [Test, TestCaseSource(nameof(GetTestCases))]
        public string objectUsedAsParamImpactsName(TestObjectClass obj)
        {
            Console.Write(obj.id);
            return obj.name;
        }

        private static IEnumerable<TestCaseData> GetTestCases()
        {
            var data = new TestObjectClass() {name = "Test Name", id = 1};
            var testCase = new TestCaseData(data);
            testCase.SetName("String used as name");
            testCase.Returns("Test Name");
            yield return testCase;
        }

        [Test, TestCaseSource(nameof(GetStringTestCasesData))]
        public string stringUsedAsParamShowsCorrectname(string str)
        {
            return str;
        }

        private static IEnumerable<TestCaseData> GetStringTestCasesData()
        {
            var testCase = new TestCaseData("Test Name");
            testCase.SetName("String used as name");
            testCase.Returns("Test Name");
            yield return testCase;
        }

        public class TestObjectClass
        {
            public string name;
            public int id;
        }
    }
Ngôn ngữ chính
Dockerfile
Star
601
Fork
159
Merge trung bình
22 giờ 18 phút
Pull request đã merge (30 ngày)
6

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

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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 nunit/docs

Tất cả issue của nunit/docs

Issue tương tự

Thêm issue về Documentation

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.