skip an unit test
34 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a list of unit tests. Some of them should be skipped.
I would assume as TestResult something like that:
TestResult with properties:
Name: 'myTestCase'
Passed: 0
Failed: 0
Incomplete: 1
Duration: 0.42
In the documentation of "TestResult" there is one point: "Tests filtered through assumption"
How can I do this?
Thanks
0 个评论
采纳的回答
Sean de Wolski
2013-12-17
编辑:Sean de Wolski
2013-12-17
To filter tests, you use an "assumable" qualification in your Test Method.
This will skip the remainder of the Test method but not fail it, marking it incomplete.
And a Quick Example:
classdef MyUnitTest < matlab.unittest.TestCase
methods(Test)
function Test(testCase)
testCase.assumeTrue(ismac,'The computer is not a Mac')
disp('This line of code will not run on my PC');
end
end
end
To run it:
T = MyUnitTest
run(T)
1 个评论
Daniel Golden
2015-3-12
To unconditionally skip a test, add:
assumeFail(testCase)
to the top of the method.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Testing Frameworks 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!