필터 지우기
필터 지우기

Testing framework: Only test specific parameter combinations

조회 수: 11 (최근 30일)
Opt User
Opt User 2017년 9월 14일
편집: Opt User 2017년 9월 14일
In an advanced parametrized test class, is it possible to omit certain combinations of parameters from the resulting test suite? For example, lets say I have:
properties (TestParameter)
parameter1 = {'a','b'};
parameter2 = {'x','y'}
end
I want to run a certain test for the parameter combinations ax, ay, and bx (omit by).

채택된 답변

Sean de Wolski
Sean de Wolski 2017년 9월 14일
You can use the TestSuite.selectIf with HasParameter and boolean logic with multiple HasParameters to remove them.
  댓글 수: 4
Steven Lord
Steven Lord 2017년 9월 14일
If you have many combinations that you want to accept and only a small number (one or two) that you want to filter, you could use one of the assume* methods on the testCase object. If the assumption fails, "The test framework then marks the test content as filtered and continues testing. Often, assumptions are used to ensure that the test is run only when certain preconditions are met. However, running the test without satisfying the preconditions does not produce a test failure."
testCase.assumeFalse(isequal(parameter1, 'b') && ...
isequal(parameter2, 'y'))
or
assumeFalse(testCase, isequal(parameter1, 'b') && ...
isequal(parameter2, 'y'))
or
% since they're both characters, we can concatenate the parameters
testCase.assumeNotEqual([parameter1, parameter2], 'by')
Sean de Wolski
Sean de Wolski 2017년 9월 14일
Or you could verifyError or verifyWarning when those parameter sets are hit to ensure that your system under test does the right thing when provided with bad inputs.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Write Unit Tests에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by