Class-Based Unit Testing

8 ビュー (過去 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 Center および File ExchangeTesting Frameworks についてさらに検索

製品


リリース

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by