Build out MATLAB test framework and core integration coverage

This commit is contained in:
Silas Oettinghaus
2026-03-24 17:23:02 +01:00
parent 9446dfb888
commit a592ebefda
154 changed files with 2281 additions and 1305 deletions

View File

@@ -1,23 +1,23 @@
function createTestFile(className, testFilePath)
% Open the file for writing
fid = fopen(testFilePath, 'w');
function createTestFile(testClassName, targetClassName, targetClassFile, testFilePath)
%CREATETESTFILE Create a placeholder test file for an unimplemented class.
% Write the basic structure for the test class
fprintf(fid, 'classdef %s_test < matlab.unittest.TestCase\n', className);
fprintf(fid, ' %% Test class for %s\n\n', className);
fprintf(fid, ' methods (Test)\n');
fprintf(fid, ' function testExample(testCase)\n');
fprintf(fid, ' %% Example test case for %s\n', className);
fprintf(fid, ' %% Add your test code here\n');
fprintf(fid, ' testCase.verifyTrue(true);\n');
fprintf(fid, ' end\n');
fprintf(fid, ' end\n');
fprintf(fid, 'end\n');
testClassName = char(testClassName);
targetClassName = char(targetClassName);
targetClassFile = char(targetClassFile);
testFilePath = char(testFilePath);
% Close the file
fclose(fid);
fprintf('Created test file: %s\n', testFilePath);
end
fid = fopen(testFilePath, "w");
assert(fid ~= -1, "Could not create test file: %s", testFilePath);
cleaner = onCleanup(@() fclose(fid));
fprintf(fid, "classdef %s < IMDDTestCase\n", testClassName);
fprintf(fid, " %% Auto-generated placeholder for %s.\n", targetClassName);
fprintf(fid, " %% Target: %s\n\n", strrep(targetClassFile, '\', '/'));
fprintf(fid, " methods (Test, TestTags = {'placeholder', 'todo'})\n");
fprintf(fid, " function testNotImplemented(testCase)\n");
fprintf(fid, " testCase.assumeFail(""Tests for %s are not implemented yet."");\n", targetClassName);
fprintf(fid, " end\n");
fprintf(fid, " end\n");
fprintf(fid, "end\n");
end