Script-Based Unit Testing Problem (from MathWorks example)

7 views (last 30 days)
Hello,
I copied and pasted the Script-Based Unit Testing Example from MathWorks http://www.mathworks.com/help/matlab/matlab_prog/write-script-based-unit-tests.html?refresh=true, but I am encountering an error. All of the tests fail because the variables in the shared variable section are not properly defined. From my understanding of the example, the variables in this section should be defined globally and can be used for any of the four tests in the example. However, there is obviously some error here.
Here's an example of the error:
Uncaught error occurred in rightTriTolTest/Test1_SumOfAngles. The remainder of the test method will not run to completion.
--------------
Error Details:
--------------
Undefined function or variable 'tri'.
I have tried creating the variables in the workspace before running the tests, but that did that work either. I also am running on R2014a, not sure if there were any changes in 2015.
Please let me know of any suggestions, I have followed the example exactly as shown in the link (copy+pasted)

Accepted Answer

Andy Campbell
Andy Campbell on 11 Jun 2015
Hello,
The Script based testing interface was added in R2014b, and in that release the shared variable section was not supported. The shared variable section feature was added in R2015a.
However, the error message you got confuses me. While the shared variable section was not supported in R2014b, we were indeed looking into it and to prevent incompatibility creating a test suite from a script which utilizes the shared variable section at all should have been an error when creating the test suite.
Can you provide details of your version, the script you are running and how you are trying to run it?
Thanks, Andy
  5 Comments
bmeyer
bmeyer on 11 Jun 2015
Ah, ok. Thanks! Do you know if there's any similar documentation on that type of unit testing for R2014a? I'm trying to fix my R2015 (having graphics problems.. different story), but it would be good to practice on the older version for now.
Andy Campbell
Andy Campbell on 12 Jun 2015
Well its not supported in R2014a at all, so you are in uncharted waters.
Your mileage may vary with the R2014b doc, which is the first release it was officially supported:

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!