classdef tReport < matlab.unittest.TestCase %TREPORT Tests for tdcs_glm / tdcs_report (Task 4: entry point + report). % % MATLAB R2025b + Statistics and Machine Learning Toolbox IS licensed % in this environment, so this suite is actually run. It does not % re-check golden values (tModels already does that); it checks the % wiring: tdcs_glm(scenario) runs end-to-end without error and writes % results/.txt, and the otherwise-branch errors on an % unrecognized scenario name. methods (Test) function testRunsScenarioAndWritesResultFile(testCase) thisDir = fileparts(mfilename('fullpath')); resultsDir = fullfile(fileparts(thisDir), 'results'); outFile = fullfile(resultsDir, 'mergeB2_full.txt'); if exist(outFile, 'file') delete(outFile); end tdcs_glm('mergeB2_full'); testCase.verifyTrue(exist(outFile, 'file') == 2, ... 'tdcs_glm did not write results/mergeB2_full.txt.'); txt = fileread(outFile); testCase.verifyNotEmpty(txt); testCase.verifyTrue(contains(txt, 'DESCRIPTIVES')); testCase.verifyTrue(contains(txt, 'INTERPRETATION')); testCase.verifyTrue(contains(txt, 'CAVEATS')); % Command-Window-only markup must be stripped from the report. testCase.verifyFalse(contains(txt, '')); % Full native GLMM summary is present for all three models % (count, rate, learning-rate): each disp() prints this header. testCase.verifyEqual(count(txt, 'Fixed effects coefficients (95% CIs):'), 3, ... 'Expected the full fitglme summary for count, rate, and learning GLMMs.'); end function testUnmergedScenarioIncludesClassification(testCase) thisDir = fileparts(mfilename('fullpath')); resultsDir = fullfile(fileparts(thisDir), 'results'); outFile = fullfile(resultsDir, 'unmerged_full.txt'); tdcs_glm('unmerged_full'); txt = fileread(outFile); testCase.verifyTrue(contains(txt, 'Classification')); testCase.verifyTrue(contains(txt, 'Electrode-Box-A')); testCase.verifyTrue(contains(txt, 'Right-Electrode')); end function testBadScenarioErrors(testCase) testCase.verifyError(@() tdcs_glm('not_a_real_scenario'), ... 'tdcs_glm:badScenario'); end end end