Class-Based Unit Testing
5 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Testing Frameworks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!