필터 지우기
필터 지우기

skip an unit test

조회 수: 44 (최근 30일)
Till Rahlf
Till Rahlf 2013년 12월 17일
댓글: Daniel Golden 2015년 3월 12일
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

채택된 답변

Sean de Wolski
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
Daniel Golden 2015년 3월 12일
To unconditionally skip a test, add:
assumeFail(testCase)
to the top of the method.

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

추가 답변 (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