據 「How to Write Tests That Share Common Set-Up Code」,纔有可能:如何將多個參數傳遞給在Matlab xUnit中共享相同設置代碼的測試?
function test_suite = testSetupExample
initTestSuite;
function fh = setup
fh = figure;
function teardown(fh)
delete(fh);
function testColormapColumns(fh)
assertEqual(size(get(fh, 'Colormap'), 2), 3);
function testPointer(fh)
assertEqual(get(fh, 'Pointer'), 'arrow');
但我不能使它具有更多參數的工作:
function test_suite = testSetupExample
initTestSuite;
function [fh,fc] = setup
fh = figure;
fc = 2;
end
function teardown(fh,fc)
delete(fh);
function testColormapColumns(fh,fc)
assertEqual(size(get(fh, 'Colormap'), fc), 3);
function testPointer(fh,fc)
assertEqual(get(fh, 'Pointer'), 'arrow');
當我runtests它說:
輸入參數「fc」未定義。
這是爲什麼?我做了一些錯誤的事情,或者在當前版本的Matlab xUnit中不支持?如何規避這種情況? PS:其實我的MATLAB需要每個功能都有一個結束。我沒有在這裏寫下它們以保持與手動示例的一致性。
感謝您的結束說明=) –