caolan / caolan/nodeunit

Data Providers

オープン
#80 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
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 の本文から書いたものです。

評価

技術スタック
javascript
領域
testing
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。