From 08416ecee5b9df6c4d62e347100ef3a774f99c33 Mon Sep 17 00:00:00 2001 From: Jeremy Huard Date: Tue, 10 Feb 2026 17:51:49 +0100 Subject: [PATCH] Added tests --- WorkshopGuide.md | 28 ++++++++++++------------ resources/project/Project.xml | 14 ++++++++++++ tests/SimulationModelTest.m | 40 +++++++++++++++++++++++++++++++++++ tests/testall.m | 17 +++++++++++++++ tests/tgenerateSimFun.m | 2 +- 5 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 tests/SimulationModelTest.m create mode 100644 tests/testall.m diff --git a/WorkshopGuide.md b/WorkshopGuide.md index 76637ba..b2cd1e4 100644 --- a/WorkshopGuide.md +++ b/WorkshopGuide.md @@ -19,19 +19,19 @@ In this workshop, you will: ## Table of Contents  [Workshop Requirements](#H_34C2FB57) - [Part 1: Getting the workshop files and configuring GitHub for automated testing and results publishing](#TMP_347b) + [Part 1: Getting the workshop files and configuring GitHub for automated testing and results publishing](#TMP_155c) - [Part 2: Generating your first tests](#TMP_8fa0) + [Part 2: Generating your first tests](#TMP_0497) - [Part 3: Finding existing tests and measuring coverage](#TMP_73c3) + [Part 3: Finding existing tests and measuring coverage](#TMP_6b12) - [Part 4: Updating badges, committing our changes, and pushing to GitHub](#TMP_5f22) + [Part 4: Updating badges, committing our changes, and pushing to GitHub](#TMP_9425) - [Part 5: Create a pull request, watch GitHub Actions automatically test your changes and publish results](#TMP_344c) + [Part 5: Create a pull request, watch GitHub Actions automatically test your changes and publish results](#TMP_3a37) - [Part 6: Compile the App in the CI workflow and download the artifact](#TMP_431c) + [Part 6: Compile the App in the CI workflow and download the artifact](#TMP_83f7) - [Workshop wrap\-up and additional information](#TMP_657c) + [Workshop wrap\-up and additional information](#TMP_2033) @@ -56,7 +56,7 @@ The following steps cover all of the things you will need to successfully comple - The workshop leverages the free repository and CI capabilities offered by GitHub and GitHub Actions - Go to: [**https://github.com/signup**](https://github.com/signup) - + # Part 1: Getting the workshop files and configuring GitHub for automated testing and results publishing @@ -308,7 +308,7 @@ Click on the 'Run App' shortcut to start the app in MATLAB: ![image_20.png](WorkshopGuide_media/image_20.png) - + # Part 2: Generating your first tests @@ -529,7 +529,7 @@ Congratulations! You just created multiple tests for your MATLAB code! It was easier than you thought, right? - + # Part 3: Finding existing tests and measuring coverage @@ -868,7 +868,7 @@ It looks like we've achieved full statement coverage for [`generateSimFun`](./co ![image_65.png](WorkshopGuide_media/image_65.png) - + # Part 4: Updating badges, committing our changes, and pushing to GitHub @@ -1088,7 +1088,7 @@ At this point, all of your changes will be pushed to GitHub. ![image_85.png](WorkshopGuide_media/image_85.png) - + # Part 5: Create a pull request, watch GitHub Actions automatically test your changes and publish results @@ -1249,7 +1249,7 @@ The code coverage report looks like this: Now anyone that visits your repository can immediately see the quality of your code, explore your test and code coverage results, and will have more confidence in the code you are writing! - + # Part 6: Compile the App in the CI workflow and download the artifact @@ -1350,7 +1350,7 @@ Once the `Deploy/ Release (main)` job is done, a new artifact is available at th You can now download the CTF file and upload it to your Web App Server! - + # Workshop wrap\-up and additional information diff --git a/resources/project/Project.xml b/resources/project/Project.xml index 11657a2..c421632 100644 --- a/resources/project/Project.xml +++ b/resources/project/Project.xml @@ -145,6 +145,20 @@ + + + + + + + + + + + + diff --git a/tests/SimulationModelTest.m b/tests/SimulationModelTest.m new file mode 100644 index 0000000..75da661 --- /dev/null +++ b/tests/SimulationModelTest.m @@ -0,0 +1,40 @@ +% This test file was generated by Copilot. Validate generated output before use. +classdef SimulationModelTest < matlab.unittest.TestCase + properties + model + end + + methods(TestMethodSetup) + function createModel(testCase) + testCase.model = SimulationModel(); + end + end + + methods(Test) + function testInitialValues(testCase) + testCase.verifyEqual(testCase.model.Kel0, testCase.model.SimFun.Parameters.Value(1)); + testCase.verifyEqual(testCase.model.Kon0, testCase.model.SimFun.Parameters.Value(2)); + testCase.verifyEqual(testCase.model.Kdeg0, testCase.model.SimFun.Parameters.Value(3)); + testCase.verifyEqual(testCase.model.Duration0, 119); + testCase.verifyEqual(testCase.model.Interval0, testCase.model.DoseTable.Interval); + testCase.verifyEqual(testCase.model.Amount0, testCase.model.DoseTable.Amount); + end + + function testSimulateMethod(testCase) + parameters = [0.1, 0.2, 0.3, 120, 50, 24]; % example parameters + testCase.model.simulate(parameters); + + testCase.verifyNotEmpty(testCase.model.SimData); + testCase.verifyNotEmpty(testCase.model.SimDataTable); + + end + + function testROIsBetweenThresholds(testCase) + parameters = [0.1, 0.2, 0.3, 120, 50, 24]; % example parameters + testCase.model.simulate(parameters); + + roiValue = testCase.model.ROIsBetweenThresholds; + testCase.verifyTrue(roiValue || ~roiValue); % should be a logical value + end + end +end \ No newline at end of file diff --git a/tests/testall.m b/tests/testall.m new file mode 100644 index 0000000..b41be2c --- /dev/null +++ b/tests/testall.m @@ -0,0 +1,17 @@ +% This is an autogenerated sample test for file all +classdef testall < matlab.unittest.TestCase + methods (Test) + function test_all(testCase) + % Specify the input(s) of all + sObj = SimulationModel; + simulate(sObj); + + % Exercise the function all + output2 = all(ismember(sObj.SimData.DataNames,["Drug","Receptor","Complex","RO"])); + + testCase.verifyClass(sObj.SimData,'SimData'); + testCase.verifyTrue(output2); + + end + end +end \ No newline at end of file diff --git a/tests/tgenerateSimFun.m b/tests/tgenerateSimFun.m index a26ed37..dd88e61 100644 --- a/tests/tgenerateSimFun.m +++ b/tests/tgenerateSimFun.m @@ -6,7 +6,7 @@ end properties (ClassSetupParameter) - MATfilename = {"test_generateSimFun.mat"} + MATfilename = {"test_generateSimFun.mat", string.empty} end properties (TestParameter)