47 lines
1.5 KiB
Matlab
47 lines
1.5 KiB
Matlab
function generateTests()
|
|
|
|
if ismac
|
|
cd('/Users/silasoettinghaus/Documents/MATLAB/imdd_simulation');
|
|
else
|
|
|
|
end
|
|
% Define the root folders for classes and tests
|
|
classesFolder = 'Classes'; % Folder containing the class files
|
|
testsFolder = 'Tests'; % Folder where test files should be created
|
|
|
|
% Create the Test folder if it doesn't exist
|
|
if ~exist(testsFolder, 'dir')
|
|
mkdir(testsFolder);
|
|
end
|
|
|
|
% Get all .m files in the Classes folder and its subfolders
|
|
classFiles = dir(fullfile(classesFolder, '**', '*.m'));
|
|
|
|
% Iterate over all class files
|
|
for i = 1:length(classFiles)
|
|
classFilePath = fullfile(classFiles(i).folder, classFiles(i).name);
|
|
[~, className, ~] = fileparts(classFilePath);
|
|
|
|
% Create corresponding test file name
|
|
testFileName = [className, '_test.m'];
|
|
testFilePath = strrep(classFilePath, classesFolder, testsFolder); % Replace folder
|
|
testFilePath = fullfile(fileparts(testFilePath), testFileName); % Append test filename
|
|
|
|
% Check if the test file already exists
|
|
if ~exist(testFilePath, 'file')
|
|
% Create the test subfolder if it doesn't exist
|
|
testSubFolder = fileparts(testFilePath);
|
|
if ~exist(testSubFolder, 'dir')
|
|
mkdir(testSubFolder);
|
|
end
|
|
|
|
% Write the skeleton test file
|
|
createTestFile(className, testFilePath);
|
|
end
|
|
end
|
|
|
|
addpath(genpath(testsFolder))
|
|
end
|
|
|
|
|