Skip a particular TestParameter in Parametrized testing

10 ビュー (過去 30 日間)
Ashish Sheikh
Ashish Sheikh 2016 年 3 月 25 日
移動済み: Steven Lord 2023 年 6 月 1 日
Hello Everyone , I am new to testing and would like to know if I can skip a particular testparameter in a Parametrized Testing.
here is what i was trying to acheive
classdef myClassA < matla.unittest.TestCase
properties(ClassSetupParameter)
A={1,212,0,21,4}
end
methods(TestClassSetup)
function setup(testCase,A)
% Rest of the code %
end
end
methods (Test)
% My Testing part
end
end
%%%Whenever the A value is 0 , It should skip the test .. I mean It should not even enter the methods(Test) part

採用された回答

Steven Lord
Steven Lord 2016 年 3 月 25 日
編集済み: Steven Lord 2016 年 3 月 25 日
Use an assumption in your TestClassSetup method. In this case, I'll use assumeNotEqual. Download the attached example then create a suite and run the suite.
suite = matlab.unittest.TestSuite.fromFile('myClassA.m');
run(suite)
When you run the suite, it should say that 8 of the test methods passed and 2 were incomplete because they were filtered. These are exactly the two that would have been executed when A took on the value 0.
If you wanted to filter just one of the methods, you could put the assumeNotEqual call inside that test method (for instance, divideByA.)
  1 件のコメント
Ashish Sheikh
Ashish Sheikh 2016 年 3 月 25 日
移動済み: Steven Lord 2023 年 6 月 1 日
Thanks..

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by