Skip to content
Snippets Groups Projects
Commit 36eb5845 authored by Lorenzo Amici's avatar Lorenzo Amici
Browse files

[unit-test-updates] split settings in saveTests and removed addpath

parent b01da53e
Branches
No related tags found
No related merge requests found
Pipeline #11845 failed
...@@ -19,22 +19,22 @@ mission = Mission(true); ...@@ -19,22 +19,22 @@ mission = Mission(true);
if isempty(rocket), rocket = Rocket(mission); end if isempty(rocket), rocket = Rocket(mission); end
if isempty(environment), environment = Environment(mission, rocket.motor); end if isempty(environment), environment = Environment(mission, rocket.motor); end
if isempty(wind), wind = Wind(mission); end if isempty(wind), wind = Wind(mission); end
if isempty(settings) if isempty(settings), settings = Settings('unitTest'); end
simPath = fullfile(fileparts(mfilename('fullpath')),'..', 'simulator', 'simulatorConfig.m');
%odePath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'common', 'settings ', 'odeConfig.m');
settings = Settings(simPath, 'ode','unitTest');
end
Settings.read(settings, options, 'unitTest'); Settings.read(settings, options, 'unitTest');
%% CREATING SIMULATOR TESTS %% CREATING SIMULATOR TESTS
if ~isempty(settings.unitTest.saveTestSimulator) if ~isempty(settings.unitTest.saveTestSimulator)
simPath = fullfile(fileparts(mfilename('fullpath')),'..', 'simulator', 'simulatorConfig.m');
simSettings = Settings('ode', simPath);
for k = 1:length(settings.unitTest.saveTestSimulator) for k = 1:length(settings.unitTest.saveTestSimulator)
TestSimulator.saveTest(settings.unitTest.saveTestSimulator{k}, mission, rocket, wind, environment, settings ); TestSimulator.saveTest(settings.unitTest.saveTestSimulator{k}, rocket, wind, environment, simSettings );
end end
end end
%% TEST APOGEE ANALYSIS %% TEST APOGEE ANALYSIS
if settings.unitTest.saveTestApogeeAnalysis if settings.unitTest.saveTestApogeeAnalysis
apoPath = fullfile(fileparts(mfilename('fullpath')),'..', 'apogeeAnalysis', 'apogeeAnalysisConfig.m');
apoSettings = Settings('ode', apoPath);
TestApogeeAnalysis.saveTest(mission); TestApogeeAnalysis.saveTest(mission);
end end
......
...@@ -3,17 +3,18 @@ classdef TestSimulator < matlab.unittest.TestCase ...@@ -3,17 +3,18 @@ classdef TestSimulator < matlab.unittest.TestCase
properties properties
settings settings
refSimulator refSimulator
rocket
wind
environment
end end
properties (MethodSetupParameter) properties (MethodSetupParameter)
verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'}; verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'};
end end
methods (TestMethodSetup) methods (TestMethodSetup)
function setup(testCase, verifiable) function setup(testCase, verifiable)
currentPath = fileparts(mfilename('fullpath')); currentPath = fileparts(mfilename('fullpath'));
addpath(genpath(currentPath));
fileName = sprintf("referenceState_%s.mat", verifiable); fileName = sprintf("referenceState_%s.mat", verifiable);
filePath = fullfile(currentPath, '..', 'data', 'testSimulator', verifiable, fileName); filePath = fullfile(currentPath, '..', 'data', 'testSimulator', verifiable, fileName);
...@@ -35,7 +36,8 @@ classdef TestSimulator < matlab.unittest.TestCase ...@@ -35,7 +36,8 @@ classdef TestSimulator < matlab.unittest.TestCase
methods (TestMethodTeardown) methods (TestMethodTeardown)
function teardown(testCase) function teardown(testCase)
close all mainSimPath = fullfile('..', '..', 'simulator');
rmpath(genpath(mainSimPath));
end end
end end
...@@ -53,10 +55,9 @@ classdef TestSimulator < matlab.unittest.TestCase ...@@ -53,10 +55,9 @@ classdef TestSimulator < matlab.unittest.TestCase
end end
methods (Static) methods (Static)
function saveTest(verifiable,mission,rocket, wind, environment, settings) function saveTest(verifiable, rocket, wind, environment, settings)
Time = tic; Time = tic;
currentPath = fileparts(mfilename('fullpath')); currentPath = fileparts(mfilename('fullpath'));
addpath(genpath(currentPath));
disp('Started saving simulator tests') disp('Started saving simulator tests')
...@@ -86,12 +87,10 @@ classdef TestSimulator < matlab.unittest.TestCase ...@@ -86,12 +87,10 @@ classdef TestSimulator < matlab.unittest.TestCase
end end
save(filePath,'stateA','stateF', 'settings',... save(filePath,'stateA','stateF', 'settings',...
'mission', 'rocket', 'environment', 'wind'); 'rocket', 'environment', 'wind');
Time = toc(Time); Time = toc(Time);
fprintf('\t %s test created in: %2.2f seconds\n',verifiable, Time) fprintf('\t %s test created in: %2.2f seconds\n',verifiable, Time)
end end
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment