Data Providers
- 主要语言
- JavaScript
- 星标
- 1.9k
- 派生
- 359
- PR 合并指标
- 30 天内没有已合并 PR
描述
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.
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先查看拟议的 `testCase` provider 约定以及 `provider test1`/`test test1` 示例。目前该 issue 处于设计讨论阶段;在开始编码之前,需要先确定一致认可的 API 和实现范围,才能完成该 issue。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- testing
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100