1
関数を再度コピーして貼り付けるのではなく、1回のテストで複数のパラメータを使用する方法はありますか? C#のためのNUnitでJS単位テストは、異なるパラメータで複数回実行されます
例:私はJsの中で欲しい
[TestCase("0", 1)]
[TestCase("1", 1)]
[TestCase("2", 1)]
public void UnitTestName(string input, int expected)
{
//Arrange
//Act
//Assert
}
:
describe("<Foo />",() => {
[TestCase("false")]
[TestCase("true")]
it("option: enableRemoveControls renders remove controls", (enableRemoveControls) => {
mockFoo.enableRemoveControls = enableRemoveControls;
//Assert that the option has rendered or not rendered the html
});
});
新しい機能を作り、それを呼び出すだけです。一般に、コールバックを 'it'(と' describe'など)に渡すので、コールバックを返す関数を作ることができます。 'function makeTest(input、expected){return function(){assert(input ==あなたがテストで 'it(" passed "、makeTest(1,1))'を呼び出すと 'それは失敗します(makeTest(" apple "、" orange ")) ' – vlaz