caolan / caolan/nodeunit

Data Providers

Đang mở
#80 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
1.9k
Fork
359
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

This is a concept used in phpunit(i assume junit too since phpunit was inspired by junit). Basically every test within a test case has an optional data provider that gets linked up to it if available. PHPUnit does this through reflection since there isn't any good reflection implementations for javascript that I know of i think using convention is appropriate. Here's my proposal:

``` javascript
exports = testCase({
'provider test1':function(){
return [
[foo,bar],//test1
[baz,gah],//test2
]

},
'test test1':function(test,value,expected){
if(value == 'foo') test.equal('bar',expected);
else if(value == 'baz') test.equal('baz',expected);

}

});

```

The nuance of the above code is the 'test test1' is run twice once passing 'foo' and 'bar' and then again passing 'baz' and 'gah'. You could write multiple test cases to support each row in the data provider but that gets a little verbose and this method is cleaner i think.

This obviously has API implications, and certain conventions would have to be adopted, so I wanted to have a discussion before looking into implementations. Sorry if this has been discussed, or has a current implementation i didn't see any.

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

Hướng nghiên cứu

Bắt đầu bằng cách xem xét quy ước `testCase` provider được đề xuất và ví dụ `provider test1`/`test test1`. Issue hiện đang là một cuộc thảo luận về thiết kế; để hoàn tất, cần thống nhất API và phạm vi triển khai trước khi có thể bắt đầu viết code.

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

Đánh giá

Công nghệ
javascript
Lĩnh vực
testing
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.