diff --git a/unitTests/unitTestClasses/TestSimulator.m b/unitTests/unitTestClasses/TestSimulator.m index 0c97974b3fab3421c966bf25c568e48df9728be7..fe6eb58f77616149ad5adc990893cb75cce14330 100644 --- a/unitTests/unitTestClasses/TestSimulator.m +++ b/unitTests/unitTestClasses/TestSimulator.m @@ -1,16 +1,17 @@ classdef TestSimulator < UnitTest properties - simulator struct % [-] + simulatorSettings struct % [-] + refSimulator end properties (TestParameter) - generalParams = {'multipleAB', 'descent6DOF', 'ballistic', 'engineCut', 'solid','HRE1', 'HRE2', 'HRE3'} + verifiable = {'multipleAB', 'descent6DOF', 'ballistic', 'engineCut', 'solid','HRE1', 'HRE2', 'HRE3'} end methods - function values = setVerifiable(externalValues) + function values = setVerifiable(testCase, externalValues) % Function to allow user to change, if wanted, the parameters with % which the test is run, so as to allow test running for certain @@ -29,7 +30,7 @@ classdef TestSimulator < UnitTest methods (Test) - function createTest(testCase, verifiable) + function createTestSimulator(testCase, verifiable) currentPath = fileparts(mfilename('fullpath')); addpath(currentPath); @@ -39,14 +40,13 @@ classdef TestSimulator < UnitTest % Load the reference file - testCase.rocket = load(filePath, 'rocket'); - testCase.motor = load(filePath, 'motor'); - testCase.environment = load(filePath, 'environment'); - testCase.wind = load(filePath, 'wind'); + testCase.rocket = load(filePath, 'rocket').rocket; + testCase.environment = load(filePath, 'environment').environment; + testCase.wind = load(filePath, 'wind').wind; % fieldName = ['referenceState_' verifiable]; testCase.refSimulator = load(filePath, 'stateA', 'stateF'); - testCase.simulatorSettings = load(filePath, 'simulatorSettings'); + testCase.simulatorSettings = load(filePath, 'simulatorSettings').simulatorSettings; % Construct the file path dynamically based on the test parameter @@ -60,15 +60,11 @@ classdef TestSimulator < UnitTest verifiable = testCase.setVerifiable(verifiable); Time = tic; - mission = Mission(true); - rocket = Rocket(Mission); - motor = Motor(mission); - environment = Environment(mission, motor); - wind = Wind(mission); + % simulator - [ascent, descent, simulatorSettings] = mainSimulator(rocket,motor, environment, wind); + [ascent, descent, simulatorSettings] = mainSimulator(); stateA = ascent(end, :); % state at end of ascent stateF = descent(end, :); % final state, at touchdown @@ -92,13 +88,12 @@ classdef TestSimulator < UnitTest function mainSimulator(testCase, verifiable) verifiable = testCase.setVerifiable(verifiable); - testCase.createTest(verifiable); + testCase.createTestSimulator(verifiable); mainSimPath = fullfile('..', 'simulator'); addpath(mainSimPath); - [postp.ascent, postp.descent, ~] = mainSimulator(testCase.simulatorSettings); - testCase.postp = postp; - testCase.verifyEqual(testCase.postp, testCase.refSimulator, 'AbsTol', testCase.absToll, ... + [postp.stateA, postp.stateF, ~] = mainSimulator(testCase.rocket, testCase.wind, testCase.environment); + testCase.verifyEqual(postp, testCase.refSimulator, 'AbsTol', testCase.absToll, ... 'RelTol', testCase.relToll) end diff --git a/unitTests/unitTestClasses/configUnitTest.m b/unitTests/unitTestClasses/configUnitTest.m index 3bbb02f98c8d365645484fa1aa5651a0ca4ecd61..1eb2b0660cadc6e349852bc845feba4289e9b78e 100644 --- a/unitTests/unitTestClasses/configUnitTest.m +++ b/unitTests/unitTestClasses/configUnitTest.m @@ -3,10 +3,11 @@ %% UNIT TESTS TO RUN % choose which folders to test opt.testSimulator = false; -opt.testCommonFunction = true; -opt.testApogeeAnalysis = true; +opt.testCommonFunction = false; +opt.testApogeeAnalysis = false; opt.testOptimization = false; -opt.testSensitivity = true; +opt.testSensitivity = false; +opt.createTestSimulator %% UNIT TEST TO CREATE % choose which folders to create data for diff --git a/unitTests/unitTestClasses/data/testSimulator/HRE1/referenceState_HRE1.mat b/unitTests/unitTestClasses/data/testSimulator/HRE1/referenceState_HRE1.mat new file mode 100644 index 0000000000000000000000000000000000000000..9a2127297b1de87e35e35b18c562640585437c59 --- /dev/null +++ b/unitTests/unitTestClasses/data/testSimulator/HRE1/referenceState_HRE1.mat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ec37c3d791b93846368ee34f7b1b088d69f1ca09b0682d7ab290d8e942d3cf3 +size 50672574 diff --git a/unitTests/unitTestClasses/mainUnitTest.m b/unitTests/unitTestClasses/mainUnitTest.m index 17c972d79feeee3bc73321703fa28655fc56b993..a2d199e408bb61480f0a7cfa351c46436689669a 100644 --- a/unitTests/unitTestClasses/mainUnitTest.m +++ b/unitTests/unitTestClasses/mainUnitTest.m @@ -42,7 +42,7 @@ end if opt.testSimulator test = TestSimulator(); - test.creatTest; + test.createTest; sensResults = run(test); end