Class-Based Unit Testing
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi!
I'm using MATLAB 2015b.
I want to create a class-based unit testing for a function like,
function y = multiply (x)
if x > 5
y = x * 2;
else
y = x * x;
end
end
and my unit test code is like that,
classdef testmultiply < matlab.unittest.TestCase
methods (Test)
function test_if_statement (testCase)
%...
end
end
end
here, I want to test the if statement for getting code coverage and also finding dead codes.
Actually, I'm able to test the multiply function with below code,
testCase.verifyEqual(y,x*2)
but, I want use an easier and more general way to test more complex functions. How can I do it in MATLAB 2015b?
Also, is there a way to unit test a Simulink Model in MATLAB 2015b without using Simulink Test, Polyspace Code Prover or something else?
Lastly, If anyone can provide me an source about unit test methods, I will be grateful.
Thanks in advance!
Bahadır
댓글 수: 0
답변 (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!