{"id":3809,"date":"2025-07-23T17:48:58","date_gmt":"2025-07-23T21:48:58","guid":{"rendered":"https:\/\/blogs.mathworks.com\/developer\/?p=3809"},"modified":"2025-07-24T09:57:54","modified_gmt":"2025-07-24T13:57:54","slug":"test-impact-analysis-test-manager","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/developer\/2025\/07\/23\/test-impact-analysis-test-manager\/","title":{"rendered":"TL;DR: Too Long; Didn&#8217;t Run: Part 2 &#8211; Ensuring Integrity of Your Commits Using MATLAB Test Manager"},"content":{"rendered":"<div class=\"content\"><!--introduction-->\r\n<p>In <a href=\"https:\/\/blogs.mathworks.com\/developer\/2025\/07\/09\/test-impact-analysis-find-tests\/\">Part 1<\/a>, we looked at how the <a href=\"https:\/\/www.mathworks.com\/help\/matlab-test\/ug\/find-tests-that-depend-on-files.html#mw_bb1343da-2b30-4bd8-9444-b7b37f93ba05\">Find Tests<\/a> button in the MATLAB Toolstrip can streamline your workflow by surfacing the relevant tests for the MATLAB file you are currently editing. While that approach works great for making changes to a single file, as development progresses and you prepare to commit a batch of changes, your focus shifts from a single file towards ensuring the integrity of those whole commits. And, a quick feedback loop is key to enabling frequent and high-quality commits before pushing to your remote branch.<\/p>\r\n<p>Starting in R2025a, the <a href=\"https:\/\/www.mathworks.com\/help\/matlab-test\/ref\/matlabtestmanager-app.html\">MATLAB Test Manager<\/a> app helps you do just that. It lets you manage a test suite that automatically detects which tests are <a href=\"https:\/\/www.mathworks.com\/help\/matlab-test\/ug\/qualify-changes-by-finding-and-running-impacted-tests.html\">impacted by changes<\/a> since your last source control commit. This means you can avoid running the full (potentially time-consuming) test suite, while still catching any regressions early.<\/p>\r\n<p>Let's look at how that works in practice.<\/p>\r\n<p>We'll take the same example from Part 1: A Simple AND Perceptron<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/example.png\" alt=\"\"> <\/p>\r\n<p>But before we dive into the example, let me take a quick moment to highlight something that is also new in MATLAB R2025a - the <strong>Source Control panel<\/strong>.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/source_control_panel.png\" alt=\"\"> <\/p>\r\n<p>This new panel, easily accessible off the sidebar, automatically detects source control folders you are actively working on. That means you can quickly get oriented without needing to dig through menus. As you make changes, it gives you a clear view of modified and untracked files, and let's you make source control actions right from the panel. You can also jump into the <b>Branch Manager<\/b> from there to manage your branches with ease. Wanna know more? Check out <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/matlab_prog\/about-mathworks-source-control-integration.html\">Source Control Integration in MATLAB documentation<\/a>.<\/p>\r\n<p>\r\n<b>Note:<\/b> Source Control integration in MATLAB supports both Git and SVN systems, but for the purposes of this post, I'll be using Git.<\/p>\r\n<p>Alright, back to our example...<\/p>\r\n<!--\/introduction-->\r\n<h3>Contents<\/h3>\r\n<div>\r\n<ul>\r\n<li>\r\n<a href=\"#adad3d86-93bd-4ee7-b057-3c4e97512f66\">Goal: Enhancing the Perceptron to Use Bias as a Parameter<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#2b020be5-56cb-4425-b3c5-dce2e58f8b26\">Solution: Trainable Bias Term<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#3ca19b33-d039-47b2-a491-dfd84fb0007a\">Utilizing MATLAB Test Manager to find and run impacted tests<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#ff4163f4-0e09-4ebc-8ec8-3f8f719541f9\">What's Next...<\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<h3>Goal: Enhancing the Perceptron to Use Bias as a Parameter<a name=\"adad3d86-93bd-4ee7-b057-3c4e97512f66\"><\/a>\r\n<\/h3>\r\n<p>\r\n<div style=\"border-left: 4px solid #007acc; background-color: #f0f8ff; padding: 12px 16px; margin: 16px 0; font-family: sans-serif;\">\r\n  <strong>Tip:<\/strong> You can access the supporting files for this post in the <a href=\"https:\/\/github.com\/mathworks\/developer-zone-blog\/tree\/2025-Test-Impact-Analysis-MATLAB-Test-Manager\">Developer Zone blog GitHub repository<\/a>. The <a href=\"https:\/\/github.com\/mathworks\/developer-zone-blog\/tree\/2025-Test-Impact-Analysis-MATLAB-Test-Manager\/before\">\"before\"<\/a> folder contains the original code to reproduce the steps outlined in this blog, while the <a href=\"https:\/\/github.com\/mathworks\/developer-zone-blog\/tree\/2025-Test-Impact-Analysis-MATLAB-Test-Manager\/after\">\"after\"<\/a> folder includes the final version of the code. \r\n<\/div>\r\n<\/p>\r\n<p>In the <a href=\"https:\/\/blogs.mathworks.com\/developer\/2025\/07\/09\/test-impact-analysis-find-tests\/\" rel=\"noopener\" target=\"_blank\">previous post<\/a>, we explored how the perceptron model classifies data by calculating a weighted sum of inputs and applying a threshold function. This approach utilizes a fixed bias term to adjust the decision boundary.<\/p>\r\n<p>In that implementation, the bias term is set to a constant value of 1, as shown below:<\/p>\r\n<pre class=\"language-matlab\">\r\n<span class=\"keyword\">function<\/span> output = calculateWeightedSum(weights, inputs)\r\n<span class=\"comment\">% Compute the weighted sum<\/span>\r\ntotal_input = sum(weights .* [inputs, 1]);\r\n<span class=\"comment\">% Activation logic<\/span>\r\n<span class=\"keyword\">if<\/span> total_input &gt; 0 <span class=\"comment\">% step function threshold; activate if weighted sum is positive<\/span>\r\n    output = 1; \r\n<span class=\"keyword\">else<\/span>\r\n    output = 0;\r\n<span class=\"keyword\">end<\/span>\r\n<span class=\"keyword\">end<\/span>\r\n<\/pre>\r\n<p>This fixed bias term simplifies the model but limits its adaptability.<\/p>\r\n<h3>Solution: Trainable Bias Term<a name=\"2b020be5-56cb-4425-b3c5-dce2e58f8b26\"><\/a>\r\n<\/h3>\r\n<p>To improve the model's flexibility and potentially enhance its performance, we propose modifying the bias term to be trainable. This adjustment allows the bias to be learned alongside the weights during training, enabling the model to better fit the data. The updated code should represent the following equation:<\/p>\r\n<p>$z = w * x + b$<\/p>\r\n<p>where <tt>b<\/tt> is now a learnable bias parameter.<\/p>\r\n<p>Let's explore how the MATLAB Test Manager can facilitate efficient implementation of this change through impact-based testing.<\/p>\r\n<h3>Utilizing MATLAB Test Manager to find and run impacted tests<a name=\"3ca19b33-d039-47b2-a491-dfd84fb0007a\"><\/a>\r\n<\/h3>\r\n<p>We'll begin by examining what tests the test manager identifies before we make any changes. When you select <b>All Tests in Current Project<\/b> , it finds, well, all the tests in your MATLAB Project.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/all_tests_in_current_project_before.png\" alt=\"\"> <\/p>\r\n<p>In R2025a, the app introduced a new option named <b>Impacted Tests Since Last Commit<\/b>. \r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/impacted_tests_menu_option.png\" alt=\"\"> <\/p>\r\nInitially, with no changes made, selecting <b>Impacted Tests Since Last Commit<\/b> reveals no affected tests, confirming that our codebase is unchanged.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/impacted_tests_before.png\" alt=\"\"> <\/p>\r\n<p>The Source Control panel agrees!<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/impacted_tests_source_control_panel_before.png\" alt=\"\"> <\/p>\r\n<p>So, let's get to work and start making the changes. We begin by creating a new branch <tt>feature\/bias<\/tt> using <b>Source Control &gt; Branch Manager<\/b>\r\n<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/impacted_tests_branch_creation.png\" alt=\"\"> <\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/git_repo_current_branch.png\" alt=\"\"> <\/p>\r\n<p>Looks like we are in a good source control state here &ndash; right branch for the change.<\/p>\r\n<p>To turn <i>bias<\/i> into a model parameter, we need to modify the functions that initialize the weights and calculate the weighted sum.<\/p>\r\n<p>\r\n<b>initializeWeights.m<\/b>\r\n<\/p>\r\n<p><u>Before:<\/u><\/p>\r\n<pre class=\"language-matlab\">\r\n<span class=\"keyword\">function<\/span> weights = initializeWeights()\r\n<span class=\"comment\">% Initialize weights randomly for two inputs and one bias<\/span>\r\nweights = rand(1, 3) * 0.5;\r\n<span class=\"keyword\">end<\/span>\r\n<\/pre>\r\n<p><u>After:<\/u><\/p>\r\n<pre class=\"language-matlab\">\r\n<span class=\"keyword\">function<\/span> [weights, bias] = initializeWeights(numInputs)\r\n<span class=\"comment\">% Initialize weights and bias randomly<\/span>\r\nweights = rand(1, numInputs); <span class=\"comment\">% Random weights for each input<\/span>\r\nbias = rand() - 0.5; <span class=\"comment\">% Bias initialized to a small random value between -0.5 and 0.5<\/span>\r\n<span class=\"keyword\">end<\/span>\r\n<\/pre>\r\n<p>\r\n<b>calculateWeightedSum.m<\/b>\r\n<\/p>\r\n<p><u>Before:<\/u><\/p>\r\n<pre class=\"language-matlab\">\r\n<span class=\"keyword\">function<\/span>output = calculateWeightedSum(weights, inputs)\r\n<span class=\"comment\">% Compute the weighted sum<\/span>\r\ntotal_input = sum(weights .* [inputs, 1]);\r\n<span class=\"comment\">% Activation logic<\/span>\r\n<span class=\"keyword\">if <\/span>total_input &gt; 0 <span class=\"comment\">% step function threshold; activate if weighted sum is positive<\/span>\r\n    output = 1;\r\n<span class=\"keyword\">else<\/span>\r\n    output = 0;\r\n<span class=\"keyword\">end<\/span>\r\n<span class=\"keyword\">end<\/span>\r\n<\/pre>\r\n<p><u>After:<\/u><\/p>\r\n<pre class=\"language-matlab\">\r\n<span class=\"keyword\">function<\/span>output = calculateWeightedSum(weights, bias, inputs)\r\n<span class=\"comment\">% Compute the weighted sum<\/span>\r\ntotal_input = sum(weights .* inputs) + bias;\r\n<span class=\"comment\">% Activation logic<\/span>\r\n<span class=\"keyword\">if <\/span>total_input &gt; 0 <span class=\"comment\">% step function threshold; activate if weighted sum is positive<\/span>\r\n    output = 1;\r\n<span class=\"keyword\">else<\/span>\r\n    output = 0;\r\n<span class=\"keyword\">end<\/span>\r\n<span class=\"keyword\">end<\/span>\r\n<\/pre>\r\n<p>OK, we made the desired changes. With those changes implemented, we'll now rely on MATLAB Test Manager to identify and run only the tests impacted by our modifications. This targeted testing approach helps maintain efficiency and ensures that we address any regressions introduced by the changes.<\/p>\r\n<p>Let's select <b>Impacted Tests Since Last Commit<\/b> in the test manager to identify the relevant tests.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/impacted_tests_first_changeset_after.png\" alt=\"\"> <\/p>\r\nThe Test Manager detected 4 impacted tests. Let's run them&hellip;\r\n<p>\r\n\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/impacted_tests_first_changeset_failures_after.png\" alt=\"\"> <\/p>\r\n<p>Uh-oh! All tests have failed.<\/p>\r\n<p>Thankfully, failure diagnostics are provided alongside the results, offering helpful insights for troubleshooting.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/initializeWeights_failure.png\" alt=\"\"> <\/p>\r\n<p>Ah, right! We modified the function signatures of <tt>initializeWeights.m<\/tt> and <tt>calculateWeightedSum.m<\/tt>. Let's address this.<\/p>\r\n<p>The first two failures are straightforward &ndash; they simply require us to update the tests corresponding to those two modified functions.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/impacted_tests_source_control_partial_fixes.png\" alt=\"\"> <\/p>\r\n<p>We re-run the tests in the MATLAB Test Manager.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/two_pass_two_failures.png\" alt=\"\"> <\/p>\r\n<p>Progress! The first two tests now pass. However, we still have two failures remaining.<\/p>\r\n<p>Upon closer inspection, it seems the remaining issues are related to other source files, such as <tt>trainPerceptron.m<\/tt> and <tt>predict.m<\/tt>. These need to be updated to account for the new trainable bias parameter and ensure it is trained alongside the weights.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/impacted_tests_source_control_all_fixes.png\" alt=\"\"> <\/p>\r\n<p>OK, we have updated those functions and their corresponding tests as well to address the regression and ensure we have a cohesive set of changes. We'll click <b>Refresh tests<\/b> in the test manager to get an updated list of impacted tests.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/impacted_tests_refresh.png\" alt=\"\"> <\/p>\r\n<p>Good news - there are no additional impacted tests. The tests identified earlier are already covering the newly updated source files.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/impacted_tests_passing_after.png\" alt=\"\"> <\/p>\r\n<p>Great! All tests are passing now, giving us confidence that the changes are compatible with the rest of the codebase.<\/p>\r\n<p>Ideally, we would add new tests to specifically target the new functionality. Even better, we could start with those new tests to drive our implementation. Depending on the complexity of the application we might also consider performing ad-hoc testing to further bolster the rigor of our qualification and ensure full confidence in the changes.<\/p>\r\n<p>The test manager supports you throughout this process by automatically identifying and running only the tests impacted by the changes in each development iteration. Much like the <b>Find Tests<\/b> feature we discussed in <a href=\"https:\/\/blogs.mathworks.com\/developer\/2025\/07\/09\/test-impact-analysis-find-tests\/\">Part 1<\/a>, <b>Impacted Tests Since Last Commit<\/b> also leverages dependency analysis to find impacted tests.<\/p>\r\n<p>An additional feature I find particularly useful in the test manager is its ability to track the history of test runs. This allows you to review previous test results, providing valuable insights as you iterate through your development process.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/mtm_test_run_history.png\" alt=\"\"> <\/p>\r\n<p>Once we've validated our changes, we can commit them using the Source Control panel:<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/commit_changes.png\" alt=\"\"> <\/p>\r\n<p>We now have a new commit<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/updated_repo_commit.png\" alt=\"\"> <\/p>\r\n<p>After committing, the test manager indicates that no tests have been impacted since the last commit. That makes sense!<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/mtm_no_impacted_tests.png\" alt=\"\"> <\/p>\r\n<p>If further development is needed for the feature, we continue to implement changes in manageable increments and commit frequently. This approach ensures the integrity of each commit while leveraging the test impact analysis capability for efficient qualification.<\/p>\r\n<p>\r\n<i>Would you consider adopting this capability in your workflow? Are there any aspects of test impact analysis or the workflow itself that we could improve to facilitate a more seamless development cycle for you? We welcome your thoughts in the comments below!<\/i>\r\n<\/p>\r\n<\/p>\r\n<h3>What's Next...<a name=\"ff4163f4-0e09-4ebc-8ec8-3f8f719541f9\"><\/a>\r\n<\/h3>\r\n<p>So far, we have conducted cycles of interactive testing using the <strong>Find Tests<\/strong> button and <strong>MATLAB Test Manager<\/strong> capabilities. Our next step will be to explore how the MATLAB build tool can help automate and further enhance your development workflow. We'll look at that in the next post. We'll specifically examine how it can leverage the same foundational test impact analysis capability to enable incremental testing and faster local automated builds as part of your pre-qualification process.<\/p>\r\n<script language=\"JavaScript\"> <!-- \r\n    function grabCode_f95637d87d1c48a58c97ad3a21a6bd06() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='f95637d87d1c48a58c97ad3a21a6bd06 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' f95637d87d1c48a58c97ad3a21a6bd06';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2025 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script>\r\n<p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\">\r\n<br>\r\n<a href=\"javascript:grabCode_f95637d87d1c48a58c97ad3a21a6bd06()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript>\r\n<\/span><\/a>\r\n<br>\r\n<br>\r\n      Published with MATLAB&reg; R2025a<br>\r\n<\/p>\r\n<\/div>\r\n<!--\r\nf95637d87d1c48a58c97ad3a21a6bd06 ##### SOURCE BEGIN #####\r\n%%\r\n% In\r\n% <https:\/\/blogs.mathworks.com\/developer\/2025\/07\/09\/test-impact-analysis-find-tests\/\r\n% Part 1>, we looked at how the\r\n% <https:\/\/www.mathworks.com\/help\/matlab-test\/ug\/find-tests-that-depend-on-files.html#mw_bb1343da-2b30-4bd8-9444-b7b37f93ba05\r\n% Find Tests> button in the MATLAB Toolstrip can streamline your workflow\r\n% by surfacing the relevant tests for the MATLAB file you are currently\r\n% editing. While that approach works great for making changes to a single\r\n% file, as development progresses and you prepare to commit a\r\n% batch of changes, your focus shifts from a single file towards ensuring\r\n% the integrity of those whole commits. And, a quick feedback loop is key\r\n% to enabling frequent and high-quality commits before pushing to your\r\n% remote branch.\r\n%\r\n% Starting in R2025a, the\r\n% <https:\/\/www.mathworks.com\/help\/matlab-test\/ref\/matlabtestmanager-app.html\r\n% MATLAB Test Manager> app helps you do just that. It lets you manage a\r\n% test suite that automatically detects which tests are\r\n% <https:\/\/www.mathworks.com\/help\/matlab-test\/ug\/qualify-changes-by-finding-and-running-impacted-tests.html\r\n% impacted by changes> since your last source control commit. This means\r\n% you can avoid running the full (potentially time-consuming) test suite,\r\n% while still catching any regressions early.\r\n% \r\n% Let's look at how that works in practice.\r\n%\r\n% We'll take the same example from Part 1: A Simple AND Perceptron\r\n%\r\n% <<example.png>>\r\n% \r\n% But before we dive into example, let me take a quick moment to highlight something\r\n% that is also new in MATLAB R2025a - the *Source Control panel*.\r\n% \r\n% <<source_control_panel.png>>\r\n% \r\n% This new panel, easily accessible off the sidebar, automatically detects\r\n% source control folders you are actively working on. That means you can\r\n% quickly get oriented without needing to dig through menus. As you make\r\n% changes, it gives you a clear view of modified and untracked files, and\r\n% let's you make source control actions right from the panel. You can also\r\n% jump into the *Branch Manager* from there to manage your branches with ease. \r\n% Wanna know more? Check out\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/matlab_prog\/about-mathworks-source-control-integration.html\r\n% Source Control Integration in MATLAB documentation>.\r\n%\r\n% *Note:* Source Control integration in MATLAB supports both Git and SVN\r\n% systems, but for the purposes of this post, I'll be using Git.\r\n%\r\n% Alright, back to our example...\r\n%\r\n%% Example Task: Enhancing the Perceptron to Use a Trainable Bias Term\r\n% \r\n% *Tip:* \r\n% You can access the supporting files for this post in the\r\n% developer-zone-blog GitHub repository. The |before| folder contains the\r\n% original code to reproduce the steps outlined in this blog, while the\r\n% |after| folder includes the final version of the code.\r\n%\r\n% In the <https:\/\/blogs.mathworks.com\/developer\/2025\/07\/09\/test-impact-analysis-find-tests\/\r\n% previous post>, we explored how the perceptron model classifies\r\n% data by calculating a weighted sum of inputs and applying a threshold\r\n% function. This approach utilizes a fixed bias term to adjust the decision\r\n% boundary.\r\n%\r\n% In that implementation, the bias term is set to a constant value of 1, as\r\n% shown below:\r\n%\r\n% <include>before\/toolbox\/calculateWeightedSum.m<\/include>\r\n%\r\n% This fixed bias term simplifies the model but limits its adaptability.\r\n% \r\n%% Proposed Enhancement: Trainable Bias Term\r\n% To improve the model's flexibility and potentially enhance its\r\n% performance, we propose modifying the bias term to be trainable. This\r\n% adjustment allows the bias to be learned alongside the weights during\r\n% training, enabling the model to better fit the data. The updated code\r\n% should represent the following equation:\r\n%\r\n% $z = w * x + b$ \r\n% \r\n% where |b| is now a learnable bias parameter.\r\n% \r\n% Let's explore how the MATLAB Test Manager can facilitate efficient\r\n% implementation of this change through impact-based testing.\r\n%\r\n%% Utilizing MATLAB Test Manager to find and run impacted tests \r\n% \r\n% We'll begin by examining what tests the test manager identifies before\r\n% we make any changes. When you select *All Tests in Current Project* , it\r\n% finds, well, all the tests in your MATLAB Project.\r\n%\r\n% <<all_tests_in_current_project_before.png>>\r\n%\r\n% In R2025a, the app introduced a new option named *Impacted Tests Since\r\n% Last Commit*. \r\n%\r\n% <<impacted_tests_menu_option.png>>\r\n%\r\n% Initially, with no changes made, selecting *Impacted Tests\r\n% Since Last Commit* reveals no affected tests, confirming that our\r\n% codebase is unchanged.\r\n%\r\n% <<impacted_tests_before.png>>\r\n%\r\n% The Source Control panel agrees!\r\n%\r\n% <<impacted_tests_source_control_panel_before.png>>\r\n%\r\n% So, let's get to work and start making the changes. We begin by creating\r\n% a new branch |feature\/bias| using *Source Control > Branch Manager*\r\n%\r\n% <<impacted_tests_branch_creation.png>>\r\n%\r\n% <<git_repo_current_branch.png>>\r\n%\r\n% Looks like we are in a good source control state here \u2013 right branch for\r\n% the change.\r\n%\r\n% To turn _bias_ into a model parameter, we need to modify the functions that\r\n% initialize the weights and calculate the weighted sum.\r\n%\r\n% \r\n% *initializeWeights.m*\r\n% \r\n% <html><u>Before:<\/u><\/html>\r\n% \r\n% <include>before\/toolbox\/initializeWeights.m<\/include>\r\n% \r\n% <html><u>After:<\/u><\/html>\r\n% \r\n% <include>after\/toolbox\/initializeWeights.m<\/include>\r\n% \r\n% *calculateWeightedSum.m* \r\n% \r\n% <html><u>Before:<\/u><\/html>\r\n%\r\n% <include>before\/toolbox\/calculateWeightedSum.m<\/include>\r\n% \r\n% <html><u>After:<\/u><\/html>\r\n% \r\n% <include>after\/toolbox\/calculateWeightedSum.m<\/include>\r\n%\r\n% OK, we made the desired changes. With those changes implemented, we'll\r\n% now rely on MATLAB Test Manager to identify and run only the tests\r\n% impacted by our modifications. This targeted testing approach helps\r\n% maintain efficiency and ensures that we address any regressions\r\n% introduced by the changes.\r\n%\r\n% Let's select *Impacted Tests Since Last Commit* \r\n% in the test manager to identify the relevant tests.\r\n%\r\n% <<impacted_tests_first_changeset_after.png>>\r\n%\r\n% The Test Manager detected 4 impacted tests. Let's run them\u2026\r\n%\r\n% <<impacted_tests_first_changeset_failures_after.png>>\r\n%\r\n% Uh-oh! All tests have failed. \r\n% \r\n% Thankfully, failure diagnostics are provided alongside the results,\r\n% offering helpful insights for troubleshooting.\r\n%\r\n% <<initializeWeights_failure.png>>\r\n%\r\n% Ah, right! We modified the function signatures of |initializeWeights.m| and\r\n% |calculateWeightedSum.m|. Let's address this. \r\n% \r\n% The first two failures are straightforward \u2013 they simply require us to\r\n% update the tests corresponding to those two modified functions.\r\n%\r\n% <<impacted_tests_source_control_partial_fixes.png>>\r\n%\r\n% We re-run the tests in the MATLAB Test Manager.\r\n%\r\n% <<two_pass_two_failures.png>>\r\n%\r\n% Progress! The first two tests now pass. However, we still have two\r\n% failures remaining. \r\n% \r\n% Upon closer inspection, it seems the remaining issues are related to\r\n% other source files, such as |trainPerceptron.m| and |predict.m|. These\r\n% need to be updated to account for the new trainable bias parameter and\r\n% ensure it is trained alongside the weights.\r\n%\r\n% <<impacted_tests_source_control_all_fixes.png>>\r\n%\r\n% OK, we have updated those functions and their corresponding tests as well\r\n% to address the regression and ensure we have a cohesive set of changes. \r\n% We'll click *Refresh tests* in the test manager to get an updated list of\r\n% impacted tests. \r\n% \r\n% <<impacted_tests_refresh.png>>\r\n%\r\n% Good news - there are no additional impacted tests. The tests identified\r\n% earlier are already covering the newly updated source files. \r\n%\r\n% <<impacted_tests_passing_after.png>>\r\n%\r\n% Great! All tests are passing now, giving us confidence that the changes\r\n% are compatible with the rest of the codebase.\r\n%\r\n% Ideally, we would add new tests to specifically target the new\r\n% functionality. Even better, we could start with those new tests to drive\r\n% our implementation. Depending on the complexity of the application we\r\n% might also consider performing ad-hoc testing to further bolster the\r\n% rigor of our qualification and ensure full confidence in the changes. \r\n% \r\n% The test manager supports you throughout this process by automatically\r\n% identifying and running only the tests impacted by the changes in each\r\n% development iteration. Much like the *Find Tests* feature we discussed in\r\n% <https:\/\/blogs.mathworks.com\/developer\/2025\/07\/09\/test-impact-analysis-find-tests\/\r\n% Part 1>, *Impacted Tests Since Last Commit* also leverages dependency\r\n% analysis to find impacted tests.\r\n%\r\n% An additional feature I find particularly useful in the test manager is\r\n% its ability to track the history of test runs. This allows you to review\r\n% previous test results, providing valuable insights as you iterate through\r\n% your development process.\r\n%\r\n% <<mtm_test_run_history.png>>\r\n%\r\n% Once we've validated our changes, we can commit them using the Source Control panel:\r\n%\r\n% <<commit_changes.png>>\r\n%\r\n% We now have a new commit\r\n%\r\n% <<updated_repo_commit.png>>\r\n%\r\n% After committing, the test manager indicates that no tests have been\r\n% impacted since the last commit. That makes sense!\r\n%\r\n% <<mtm_no_impacted_tests.png>>\r\n%\r\n% If further development is needed for the feature, we continue to\r\n% implement changes in manageable increments and commit  frequently. This\r\n% approach ensures the integrity of each commit while leveraging the test\r\n% impact analysis capability for efficient qualification.\r\n%\r\n% _Would you consider adopting this capability in your workflow? Are there\r\n% any aspects of test impact analysis or the workflow itself that we could\r\n% improve to facilitate a more seamless development cycle for you? We\r\n% welcome your thoughts in the comments below!_\r\n%\r\n%% What's Next...\r\n% \r\n% So far, we have conducted cycles of interactive testing using the *Find\r\n% Tests* button and *MATLAB Test Manager* capabilities. Our  next step will\r\n% be  to explore how the MATLAB  build tool can help automate and further\r\n% enhance your development workflow. We'll look at that in the next post. \r\n% We'll specifically examine how it can leverage the same foundational \r\n% test impact analysis capability to enable incremental testing and faster \r\n% local automated builds as part of your pre-qualification process.\r\n##### SOURCE END ##### f95637d87d1c48a58c97ad3a21a6bd06\r\n-->\r\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/developer\/files\/featured_image_tia_part2.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction-->\r\n<p>In <a href=\"https:\/\/blogs.mathworks.com\/developer\/2025\/07\/09\/test-impact-analysis-find-tests\/\">Part 1<\/a>, we looked at how the <a href=\"https:\/\/www.mathworks.com\/help\/matlab-test\/ug\/find-tests-that-depend-on-files.html#mw_bb1343da-2b30-4bd8-9444-b7b37f93ba05\">Find Tests<\/a> button in the MATLAB Toolstrip can streamline your workflow by surfacing the relevant tests for the MATLAB file you are currently editing. While that approach works great for making changes to a single file, as development progresses and you prepare to commit a batch of changes, your focus shifts from a single file towards ensuring the integrity of those whole commits. And, a quick feedback loop is key to enabling frequent and high-quality commits before pushing to your remote branch.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/developer\/2025\/07\/23\/test-impact-analysis-test-manager\/\">read more >><\/a><\/p>","protected":false},"author":222,"featured_media":3884,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[44,13,20,57,7,1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/posts\/3809"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/users\/222"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/comments?post=3809"}],"version-history":[{"count":50,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/posts\/3809\/revisions"}],"predecessor-version":[{"id":4037,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/posts\/3809\/revisions\/4037"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/media\/3884"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/media?parent=3809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/categories?post=3809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/tags?post=3809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}