How to write multiple test functions in a single file (TDD implementation)

1 回表示 (過去 30 日間)
Vinay Vittal Karagod
Vinay Vittal Karagod 2017 年 1 月 16 日
回答済み: Stephen Carter 2017 年 4 月 28 日
I have different test cases to test the different functions. I want to write all the different functions in one .m file and one test file to check all the different test cases.
https://www.mathworks.com/help/matlab/matlab_prog/write-simple-test-case-with-functions.html#zmw57dd0e66668
I followed the above link but I can see only one test function implemented but I want to implement multiple functions. can anyone help me in implementing multiple functions ?

回答 (1 件)

Stephen Carter
Stephen Carter 2017 年 4 月 28 日
Each subfunction that starts or end with "test" is a seperate test procedure in the test file.
For example:
function tests = myManyTests()
tests = functiontests(localfunctions);
end
function test_function1()
% ...
end
function test_function2()
% ...
end
function test_function3()
% ...
end

カテゴリ

Help Center および File ExchangeVerification, Validation, and Test についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by