Class-Based Unit Testing

조회 수: 4 (최근 30일)
Bahadir Erdenk
Bahadir Erdenk 2021년 2월 12일
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개)

카테고리

Help CenterFile Exchange에서 Testing Frameworks에 대해 자세히 알아보기

제품


릴리스

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by