You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(2016b compatibility): add section about 2016b changes
* New documentation file about changes needed for 2016b+
* Example code referenced from documentation
* HTML version
* Referenced in TOC and front page
</style></head><body><divclass="content"><h1><ahref="../index.html">MATLAB xUnit Test Framework</a>: Compatibility with R2016b</h1><!--introduction--><p>Significant changes were made to MATLAB in R2016b that affect how xUnit works. If you wrote tests using version 4.0.0 or earlier, you may need to make slight changes to your tests to make them work on 2016b and subsequent releases.</p><p>An incredible amount of effort was expended trying to find a solution that would allow all existing tests to continue to run on 2016b and on previous versions, with no changes, but we don't believe that to be possible. (Although you are welcome to try, and submit a pull request if you succeed.)</p><p>Listed below are the different scenarios you may be in, and what to do about it.</p><!--/introduction--><h2>Contents</h2><div><ul><li><ahref="#1">I use class-based tests</a></li><li><ahref="#3">I use function-based tests</a></li><li><ahref="#5">I use function-based tests (and I only care about 2016a or older)</a></li><li><ahref="#6">I use function-based tests (and I only care about 2013b or newer)</a></li><li><ahref="#7">I use function-based tests (and I don't fall into either prior category)</a></li></ul></div><h2>I use class-based tests<aname="1"></a></h2><p>My tests start like this:</p><preclass="codeinput">dbtype <spanclass="string">examples_2016b_compatibility/TestUsingClasses.m</span><spanclass="string">1</span>
70
+
</pre><preclass="codeoutput">
71
+
1 classdef TestUsingClasses < TestCase
72
+
</pre><p>Five points for using classes! You can stop reading now. You're not affected.</p><h2>I use function-based tests<aname="3"></a></h2><p>My tests start like this:</p><preclass="codeinput">dbtype <spanclass="string">examples_2016b_compatibility/testUsingFunctionsDeprecated.m</span><spanclass="string">1:2</span>
73
+
</pre><preclass="codeoutput">
74
+
1 function testSuite = testUsingFunctionsDeprecated
75
+
2 inittestsuite
76
+
</pre><p>The way this worked is that <tt>inittestsuite</tt> was actually a script, called from within the scope of your test function. And as a result of that, it had access to all the subfunctions that were your actual tests, and was able to build a test suite that way. Starting with 2016b, scripts called from functions no longer have access to the caller's scope, and this strategy will not (can not) work.</p><p>The replacement is to construct a test suite out of function handles, while still in the scope of <tt>testUsingFunctionsDeprecated</tt>. In 2014b and newer, the built-in function <tt>localfunctions</tt> can be used. In 2013b and 2014a, <tt>localfunctions</tt> is not able to see functions inside of packages, and is somewhat broken for our purposes. In 2013a and older releases, <tt>localfunctions</tt> doesn't exist.</p><p>This gisves us the following three situations you may be in.</p><h2>I use function-based tests (and I only care about 2016a or older)<aname="5"></a></h2><p>You <i>technically</i> don't need to change anything. Your tests will continue to work. However, <tt>inittestsuite</tt> is now deprecated, and you will receive warnings when your tests run. This functionality will be removed in a future major release.</p><h2>I use function-based tests (and I only care about 2013b or newer)<aname="6"></a></h2><p>The replacement for <tt>inittestsuite</tt> is <tt>buildFunctionHandleTestSuite</tt>, and you will pipe the cell array from <tt>localfunctions</tt> into it.</p><preclass="codeinput">dbtype <spanclass="string">examples_2016b_compatibility/testUsingFunctions.m</span><spanclass="string">1:2</span>
</pre><h2>I use function-based tests (and I don't fall into either prior category)<aname="7"></a></h2><p>If you have function-based tests that you want or need to run against <b>both</b> 2016b or newer <b>and</b> 2013a or older, then you have additional work to do. You will have to first create the cell array of function handles, using some seriously fugly syntax. Then you can call <tt>buildFunctionHandleTestSuite</tt> with the cell array you created.</p><preclass="codeinput">dbtype <spanclass="string">examples_2016b_compatibility/testUsingFunctionsAndSubFunHandles.m</span><spanclass="string">1:4</span>
81
+
</pre><preclass="codeoutput">
82
+
1 function testSuite = testUsingFunctionsAndSubFunHandles
</pre><p>Unfortunately, there is no other way to handle all test suite types across that many releases.</p><p><ahref="../index.html">Back to MATLAB xUnit Test Framework</a></p><pclass="footer"><br><ahref="http://www.mathworks.com/products/matlab/">Published with MATLAB® R2016a</a><br></p></div><!--
87
+
##### SOURCE BEGIN #####
88
+
%% <../index.html MATLAB xUnit Test Framework>: Compatibility with R2016b
89
+
% Significant changes were made to MATLAB in R2016b that affect how xUnit
90
+
% works. If you wrote tests using version 4.0.0 or earlier, you may need
91
+
% to make slight changes to your tests to make them work on 2016b and
92
+
% subsequent releases.
93
+
%
94
+
% An incredible amount of effort was expended trying to find a solution that
95
+
% would allow all existing tests to continue to run on 2016b and on previous versions,
96
+
% with no changes, but we don't believe that to be possible. (Although you
97
+
% are welcome to try, and submit a pull request if you succeed.)
98
+
%
99
+
% Listed below are the different scenarios you may be in, and what to do
0 commit comments