{"id":3384,"date":"2025-07-09T14:47:45","date_gmt":"2025-07-09T18:47:45","guid":{"rendered":"https:\/\/blogs.mathworks.com\/developer\/?p=3384"},"modified":"2025-07-09T16:07:58","modified_gmt":"2025-07-09T20:07:58","slug":"test-impact-analysis-find-tests","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/developer\/2025\/07\/09\/test-impact-analysis-find-tests\/","title":{"rendered":"TL;DR: Too Long; Didn&#8217;t Run: Part 1 &#8211; Finding the Right Tests from your Editor"},"content":{"rendered":"<div class=\"content\"><!--introduction-->\r\n<p>Welcome back! As promised, I am here to kick things off with Part 1 of our <a href=\"https:\/\/blogs.mathworks.com\/developer\/2025\/07\/02\/test-impact-analysis-intro\">blog series<\/a> on impact-based test selection. Lezz go!<\/p>\r\n<p>Imagine you are developing an application and writing code in your MATLAB development environment.<\/p>\r\n<p>Code changes, even small ones, can introduce unintended consequences in complex software systems. Running an entire test suite to validate every change slows down feedback loops and reduces development efficiency. For new contributors, unfamiliarity with the codebase further amplifies this challenge, making it harder to identify which tests are relevant.<\/p>\r\n<p>When you make code changes, your focus is usually on a specific file. You want to iterate swiftly and confidently without losing context. To streamline this just-in-time validation process, <b><a href=\"https:\/\/www.mathworks.com\/products\/matlab-test.html\">MATLAB Test<\/a> R2025a<\/b> integrates dependency-based test impact analysis directly into the MATLAB Editor. This makes it easier to find and run only the tests related to the file you are actively working on.<\/p>\r\n<p>At the heart of this is the new <strong><a href=\"https:\/\/www.mathworks.com\/help\/matlab-test\/ug\/find-tests-that-depend-on-files.html\">Find Tests<\/a><\/strong> button on the MATLAB Toolstrip that shows up if you have the MATLAB Test toolbox. MATLAB easily analyzes dependencies for the open file and identifies relevant tests. These are automatically populated in the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/testbrowser-app.html\">Test Browser<\/a>, so you can run just those necessary tests without ever leaving the Editor or searching manually through your project.<\/p>\r\n<p><img decoding=\"async\" loading=\"lazy\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/FindTests.png\" width=\"640\" height=\"240\" alt=\"\"> <\/p>\r\n<p>Test impact analysis uses MATLAB dependency analysis. Tim Johns wrote a nice post on <a href=\"https:\/\/blogs.mathworks.com\/developer\/2023\/10\/26\/dependency-based-test-selection\/\">Dependency-based Test Selection<\/a> that you may be interested in checking out as well. It also touches on the nuances and limitations of static analysis that one ought to keep in mind. \r\n<!--\/introduction-->\r\n<h3>Contents<\/h3>\r\n<div>\r\n<ul>\r\n<li>\r\n<a href=\"#abffce27-fc77-4511-aa69-baf502359a7e\">Example: Testing a Simple Perceptron<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#8c8bf6b8-ac6d-43a7-8a75-37916a8b3040\">Stay Focused. Stay In Context.<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#a0fe6420-827d-4038-8b49-1457f765321b\">Key Considerations<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#8605320e-0174-4dd2-9478-bdeee4645a5a\">In Summary...<\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<h2>Example: Testing a Simple Perceptron<a name=\"abffce27-fc77-4511-aa69-baf502359a7e\"><\/a>\r\n<\/h2>\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  If you have MATLAB Test R2025a, and want to follow along or reproduce the content of this post later, you can access all the code now at our new <a href=\"https:\/\/github.com\/mathworks\/developer-zone-blog\/tree\/2025-Test-Impact-Analysis-Find-Tests\">Developer Zone Blog GitHub repo<\/a>.\r\n<\/div>\r\n<\/p>\r\n<p>\r\nWhile impact-based testing shines brightest in large projects, let's take a simple example to see how it works in practice. Our example here is a simple neural network, <a href=\"https:\/\/www.codecademy.com\/learn\/perceptrons-and-neural-nets-skill-path\/modules\/perceptrons-skill-path\/cheatsheet\">perceptron<\/a> , that creates a binary linear classification model that simulates the task of decision making. You don't need to fully understand the details of how it works; in fact, it's better if you don't. Like the scenario of a new contributor unfamiliar with the codebase, this lets you see how the <strong>Find Tests<\/strong> feature helps you identify which tests are relevant, without having to reverse-engineer everything first.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/project_setup.png\" alt=\"\"> <\/p>\r\n<p>The project has some source code and tests. The main goal of a perceptron is to make accurate classifications. This is achieved through optimizing the weights of the perceptron so the model can be better trained. We start off by calculating the weighted sum and that is used to train the model and use the trained model for prediction.<\/p>\r\n<h3>Let's make a change<\/h3> \r\n<p>\r\nSay, you are interested in determining how changes to the initialization of weights affect the classifier's performance. So, you open the <tt>initializeWeights.m<\/tt> file in the MATLAB Editor.<\/p>\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/initializeWeights_before-1.png\" width=\"780\" height=\"360\" alt=\"\"> <\/p>\r\n<p>You change the scaling factor from 0.1 to 0.5 and want to validate the change. Luckily the project has tests. In this case, there's only a handful of them, but you are not sure if all of them are relevant to this file and change, and how long it would take to run them all. You want your iterations to be quick. The new <strong>Find Tests<\/strong> button to the rescue!<\/p>\r\n<p>\r\n<img decoding=\"async\" loading=\"lazy\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/initializeWeights_after-1.png\" width=\"780\" height=\"360\" alt=\"\"> <\/p>\r\n<p>When you click the <strong>Find Tests<\/strong> button, it prompts you to choose the folder where tests are located. It runs MATLAB dependency analysis and populates the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/testbrowser-app.html\">Test Browser<\/a> app with just those related tests.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/testbrowser_related_tests.png\" alt=\"\"> <\/p>\r\n<p>Now you can interact with the Test Browser as you normally would. Click the <strong>Run Tests<\/strong> button to run the test suite and see how your changes impact the perceptron performance.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/testbrowser_related_tests_run.png\" alt=\"\"> <\/p>\r\n<p>Hmm, changing the scaling factor to 0.5 didn't seem to have much impact. Perhaps that is because this is a simple AND perceptron. But that tighter, faster feedback loop gives you confidence to keep experimenting or moving forward with the change.<\/p>\r\n<h2>Stay Focused. Stay In Context.<a name=\"8c8bf6b8-ac6d-43a7-8a75-37916a8b3040\"><\/a>\r\n<\/h2>\r\n<p>When you're editing a file, that file is your primary focus. Everything else can be noise. <strong>Find Tests<\/strong> optimizes for that mental context by populating just the relevant tests in a clean Test Browser, reducing distraction and cognitive load.<\/p>\r\n<p>You can also then enable coverage collection in the Test Browser to see which parts of your modified or new code are exercised by existing tests. This helps you identify and close coverage gaps before pushing your changes. (The <strong>Generate Tests<\/strong> button right next to <strong>Find Tests<\/strong> can also help here.)<\/p>\r\n<h2>Key Considerations<a name=\"a0fe6420-827d-4038-8b49-1457f765321b\"><\/a>\r\n<\/h2>\r\n<p>Test impact analysis is only as effective as our test coverage. If there are no tests or not enough tests in the project, there's little to analyze and benefit from. The richer the test suite, the better the outcome from test impact analysis. The better the test impact analysis, the better the confidence in making code changes.<\/p>\r\n<p>\r\n<strong>Find Tests<\/strong> determines dependencies (a.k.a. impact) with static analysis, and like any static analysis technique, it has <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/dependencyanalyzer-app.html#mw_16e23e55-ae1c-4228-8f5f-97273d840a70\">limitations<\/a>. It's not perfect or exhaustive. Think of it as a performance optimization that benefits from user vigilance &minus; <strong>trust but verify<\/strong>. It is still recommended to run your full test suite at key stages in your development and release cycle.<\/p>\r\n<p>\r\n<div class=\"info-box\">\r\n    <span class=\"info-icon\">&#x1f4a1;<\/span>\r\n    <span>\r\n      <strong>Tip:<\/strong> If you know of a test that needs to run due to an untracked dependency you can still manually add it via the Test Browser after you \"find the tests\".\r\n    <\/span>\r\n  <\/div>\r\n<\/p>\r\n<h2>In Summary...<a name=\"8605320e-0174-4dd2-9478-bdeee4645a5a\"><\/a>\r\n<\/h2>\r\n<p>You can find impacted tests manually, but by surfacing the relevant tests just at the right time, MATLAB Test's <strong>Find Tests<\/strong> reduces the cognitive load, time and effort required to validate changes&mdash;especially in large projects with extensive test suites&mdash;and provides immediate guidance for new contributors or when working in unfamiliar areas of the codebase. Ultimately, it helps maintain high confidence in code changes while accelerating development workflows.<\/p>\r\n<p><em>How do you see this feature helping your day-to-day development workflows? What other tools or capabilities would you like to see integrated more tightly with <strong>Find Tests<\/strong> and the Editor to further assist you in completing your workflows without having to switch too many contexts? What else do you see valuable for a more rigorous test impact analysis?<\/em><\/p>\r\n<p>Let us know in the comments!<\/p>\r\n<script language=\"JavaScript\"> <!-- \r\n    function grabCode_b75ca75c937144bb8eb6af0eb5a5cc78() {\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='b75ca75c937144bb8eb6af0eb5a5cc78 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' b75ca75c937144bb8eb6af0eb5a5cc78';\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_b75ca75c937144bb8eb6af0eb5a5cc78()\"><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\nb75ca75c937144bb8eb6af0eb5a5cc78 ##### SOURCE BEGIN #####\r\n%% \r\n% Welcome back! As promised, I am here to kick things off with Part 1 of our\r\n% <https:\/\/blogs.mathworks.com\/developer\/2025\/07\/02\/test-impact-analysis-intro\/\r\n% blog series> on impact-based test selection.\r\n%\r\n% Imagine you are developing an application and writing code in your MATLAB\r\n% development environment.\r\n% \r\n% Code changes, even small ones, can introduce unintended consequences in\r\n% complex software systems. Running an entire test suite to validate every\r\n% change slows down feedback loops and reduces development efficiency. For\r\n% new contributors, unfamiliarity with the codebase further amplifies this\r\n% challenge, making it harder to identify which tests are relevant.\r\n% \r\n% When you make code changes, your focus is usually on a specific file. You\r\n% want to iterate swiftly and confidently without losing context. To\r\n% streamline this just-in-time validation process, <https:\/\/www.mathworks.com\/products\/matlab-test.html MATLAB Test> *R2025a*\r\n% integrates dependency-based test impact analysis directly in the MATLAB\r\n% Editor. This makes it easier to find and run only the tests related to\r\n% the file you are actively working on.\r\n% \r\n% At the heart of this is the new *Find Tests* button on the MATLAB\r\n% Toolstrip that shows up if you have the MATLAB Test toolbox. MATLAB\r\n% easily analyzes dependencies for the open file and identifies relevant\r\n% tests. These are automatically populated in the\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/testbrowser-app.html Test\r\n% Browser>, so you can run just those necessary tests without ever leaving\r\n% the Editor or searching manually through your project.\r\n% \r\n% Test impact analysis uses MATLAB dependency analysis. Tim Johns wrote \r\n% a nice post on <https:\/\/blogs.mathworks.com\/developer\/2023\/10\/26\/dependency-based-test-selection\/\r\n% Dependency-based Test Selection> that you may be interested in checking out as well. \r\n% It also touches on the nuances and limitations of static analysis that \r\n% one ought to keep in mind. \r\n% \r\n%% Example: Testing a Simple Perceptron\r\n% \r\n% If you have MATLAB Test R2025a, and want to follow along or reproduce the content of this post later,\r\n% you can access all the code now at our new <https:\/\/github.com\/mathworks\/developer-zone-blog\/tree\/2025-Test-Impact-Analysis-Find-Tests Developer Zone Blog GitHub repo>.\r\n% \r\n% While impact-based testing shines brightest in large projects, let's take\r\n% a simple example to see how it works in practice. Our example here is a simple neural network,\r\n% <https:\/\/www.codecademy.com\/learn\/perceptrons-and-neural-nets-skill-path\/modules\/perceptrons-skill-path\/cheatsheet\r\n% perceptron> , that creates a binary linear classification model that\r\n% simulates the task of decision making. You don't need to fully understand\r\n% the details of how it works; in fact, it's better if you don't. Like the\r\n% scenario of a new contributor unfamiliar with the codebase, this lets you\r\n% see how the *Find Tests* feature helps you identify which tests are\r\n% relevant, without having to reverse-engineer everything first.\r\n% \r\n% <<project_setup.png>>\r\n% \r\n% The project has some source code and tests. The main goal of a perceptron\r\n% is to make accurate classifications. This is achieved through optimizing\r\n% the weights of the perceptron so the model can be better trained. We\r\n% start off by calculating the weighted sum and that is used to train the\r\n% model and use the trained model for prediction.\r\n% \r\n% *Let's make a change*\r\n%\r\n% Say, you are interested in determining how changes to the initialization\r\n% of weights affect the classifier's performance. So, you open the\r\n% |initializeWeights.m| file in the MATLAB Editor.\r\n% \r\n% <<initializeWeights_before.png>>\r\n% \r\n% You change the scaling factor from 0.1 to 0.5 and want to validate the\r\n% change. Luckily the project has tests. In this case, there's only a\r\n% handful of them, but you are not sure if all of them are relevant to this\r\n% file and change, and how long it would take to run them all. You want\r\n% your iterations to be quick. The new *Find Tests* button to the rescue!\r\n% \r\n% <<initializeWeights_after.png>>\r\n% \r\n% When you click the *Find Tests* button, it prompts you to choose the\r\n% folder where tests are located. It runs MATLAB dependency analysis and\r\n% populates the\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/testbrowser-app.html Test\r\n% Browser> app with just those related tests.\r\n% \r\n% <<testbrowser_related_tests.png>>\r\n% \r\n% Now you can interact with the *Test Browser* as you normally would. Click\r\n% the *Run Tests* button to run the test suite and see how your changes\r\n% impact the perceptron performance. \r\n%\r\n% Hmm, changing the scaling factor to\r\n% 0.5 didn't seem to have much impact. Perhaps that is because this is a\r\n% simple AND perceptron. But that tighter, faster feedback loop gives you\r\n% confidence to keep experimenting or moving forward with the change.\r\n% \r\n% <<testbrowser_related_tests_run.png>>\r\n% \r\n%% Stay Focused. Stay In Context. \r\n% When you're editing a file, that file is your primary focus. Everything\r\n% else can be noisy. *Find Tests* optimizes for that mental context by\r\n% populating just the relevant tests in a clean Test Browser, reducing\r\n% distraction and cognitive load.\r\n% \r\n% You can also then enable coverage collection in the Test Browser to see\r\n% which parts of your modified or new code are exercised by existing tests.\r\n% This helps you identify and close coverage gaps before pushing your\r\n% changes. (The *Generate Tests* button right next to *Find Tests* can also\r\n% help here.)\r\n% \r\n%% Key Considerations \r\n% Test impact analysis is only as effective as our test coverage. If there\r\n% are no tests or not enough tests in the project, there's little to\r\n% analyze and benefit from. The richer the test suite, the better the\r\n% outcome from test impact analysis. The better the test impact analysis,\r\n% the better the confidence in making code changes.\r\n% \r\n% *Find Tests* determines dependencies (a.k.a. impact) with static analysis,\r\n% and like any static analysis technique, it has <https:\/\/www.mathworks.com\/help\/matlab\/ref\/dependencyanalyzer-app.html#mw_16e23e55-ae1c-4228-8f5f-97273d840a70 limitations>. \r\n% It's not perfect or exhaustive. Think of it as a performance optimization that\r\n% benefits from user vigilance \u2212 trust but verify. It is still recommended\r\n% to run your full test suite at key stages in your development and release\r\n% cycle. Check out the Dependency-based Test Selection blog post for more\r\n% insights. \r\n%\r\n%       *Tip*: If you know of a test that needs to run due to an untracked\r\n%       dependency you can still manually add it via the Test Browser\r\n%       after you \"find the tests\".\r\n% \r\n%% In Summary...\r\n% You can find impacted tests manually, but by surfacing the relevant tests\r\n% just at the right time, MATLAB Test's *Find Tests* reduces the cognitive\r\n% load, time and effort required to validate changes\u2014especially in large\r\n% projects with extensive test suites\u2014and provides immediate guidance for\r\n% new contributors or when working in unfamiliar areas of the codebase.\r\n% Ultimately, it helps maintain high confidence in code changes while\r\n% accelerating development workflows.\r\n% \r\n% _How do you see this feature helping your day-to-day development\r\n% workflows? What other tools or capabilities would you like to see\r\n% integrated more tightly with *Find Tests* and the Editor to further\r\n% assist you in completing your workflows without having to switch too many\r\n% contexts? What else do you see valuable for a more rigorous test impact\r\n% analysis?_ \r\n% \r\n% Let us know in the comments!\r\n##### SOURCE END ##### b75ca75c937144bb8eb6af0eb5a5cc78\r\n-->\r\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/developer\/files\/find-tests-button.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction-->\r\n<p>Welcome back! As promised, I am here to kick things off with Part 1 of our <a href=\"https:\/\/blogs.mathworks.com\/developer\/2025\/07\/02\/test-impact-analysis-intro\">blog series<\/a> on impact-based test selection. Lezz go!... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/developer\/2025\/07\/09\/test-impact-analysis-find-tests\/\">read more >><\/a><\/p>","protected":false},"author":222,"featured_media":3800,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,44,13,57,7],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/posts\/3384"}],"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=3384"}],"version-history":[{"count":78,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/posts\/3384\/revisions"}],"predecessor-version":[{"id":3797,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/posts\/3384\/revisions\/3797"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/media\/3800"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/media?parent=3384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/categories?post=3384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/tags?post=3384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}