1
私は1つの単体テストクラスで複数の設定を使用する必要があります。また、私はメソッドをテストするために多くのケースを使用する必要があります。私としては、それは以下のようなもののために一緒にランナーパラメータ化と理論を使用するのが最も自然である:TheoriesとParameterizedユニットテストランナーを一緒に使うには?
@RunWith(ParameterizedTheories.class)
public class Tests {
Setup o;
@Parameters(name = "{index}: {0}")
public static Iterable<Object> data() {
return asList(new Object[][]{
asArray("First", Tests::setup1),
asArray("Second",Tests::setup2),
});
public Tests(String name, Setuper setuper) {
Setup o = setuper.setup();
}
@Theory
public void AddSevenTest(
@TestedOn(ints = {0, 5, 10})int x){
o.implementation.addSevenAnd(x);
verify(o.storageMock).save(x + 7);
}
static Setup setup1(){
// ...
}
static Setup setup2(){
// ...
}
interface Setuper {
Setup setup();
}
static class Setup {
IStorage storageMock;
ITesting implementation;
}
}
を私は使用のためには何も見つかりませんでした。私を助けることは何ですか?何?