Data Providers
- Langage dominant
- JavaScript
- Étoiles
- 1.9k
- Forks
- 359
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Commencez par examiner la convention proposée pour le provider `testCase` ainsi que l’exemple `provider test1`/`test test1`. L’issue est actuellement une discussion de conception ; sa finalisation nécessiterait de convenir de l’API et du périmètre de l’implémentation avant de pouvoir commencer à coder.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- testing
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100