function runTests(obj)
%

%   Copyright 2009-2021 The MathWorks, Inc.
    
    obj.turnOffAndStoreWarningStatus;
    obj.initForSim;    
    
    [sldvData, sampleTimeInformation] = obj.generateDataForLogging;
    obj.checkRefModelSampleTimes(sampleTimeInformation);   
    
    paramNameValStruct = obj.getBaseSimStruct;                
    
    if ~isempty(obj.SldvHarnessModelH)           
        numTests = length(obj.TcIdx);  
        obj.SigBTime = obj.HarnessSource.getTimeAsCellArray;
        modelToSim = get_param(obj.SldvHarnessModelH,'Name');
        for idx=1:numTests            
            obj.HarnessSource.setActiveTestcase(obj.TcIdx(idx));            
            paramNameValStructCurrent = obj.modifySimstruct(obj.TcIdx(idx), paramNameValStruct);
            simOut = sim(modelToSim, paramNameValStructCurrent);
            % Group signals that are bus element ports and belong to the
            % same bus
            modelToLog = sldvData.LoggedTestUnitInfo.SldvHarnessModel.TestUnitModel.Name;
            modelH = get_param(modelToLog,'handle');
            [inPorts,~] = Sldv.utils.getSubSystemPortBlks(modelH);
            if any(contains(get_param(inPorts, 'IsBusElementPort'),'on'))
                % The model contains in bus elements
                portCompiledInfo = sldvData.LoggedTestUnitInfo.SldvHarnessModel.TestUnitModel.mdlFlatIOInfo.InportCompInfo;
                inputPortInfo = sldvData.LoggedTestUnitInfo.SldvHarnessModel.TestUnitModel.InputPortInfo;
                outDataSet = sldvshareprivate('restructureLoggedInputData',simOut,inputPortInfo,portCompiledInfo,paramNameValStruct.SignalLoggingName,modelH);
                simOut.(paramNameValStruct.SignalLoggingName) = outDataSet;
            end
            sldvData.TestCases(idx).dataValues = ...
                obj.deriveFunctionalTestCase(...
                simOut.find(paramNameValStruct.SignalLoggingName), ...
                idx);
        end                                       
    else                                                    
        modelToSim = get_param(obj.TopLevelModelH,'Name');
        simOut = sim(modelToSim, paramNameValStruct);
        % Group signals that are bus element ports and belong to the same
        % bus
        modelToLog = sldvData.LoggedTestUnitInfo.ModelBlock.ReferencedModel.Name;
        modelH = get_param(modelToLog,'handle');
        [inPorts,~] = Sldv.utils.getSubSystemPortBlks(modelH);
        if any(contains(get_param(inPorts, 'IsBusElementPort'),'on'))
            % The model contains in bus elements
            portCompiledInfo = sldvData.LoggedTestUnitInfo.ModelBlock.ReferencedModel.mdlFlatIOInfo.InportCompInfo;
            inputPortInfo = sldvData.LoggedTestUnitInfo.ModelBlock.ReferencedModel.InputPortInfo;
            outDataSet = sldvshareprivate('restructureLoggedInputData',simOut,inputPortInfo,portCompiledInfo,paramNameValStruct.SignalLoggingName,modelH);
            simOut.(paramNameValStruct.SignalLoggingName) = outDataSet;
        end
        sldvData.TestCases.dataValues = ...
                obj.deriveFunctionalTestCase(...
                simOut.find(paramNameValStruct.SignalLoggingName), ...
                1);
    end
    
    obj.convertLoggedDataToCellFormat(sldvData);            
end
