matlab.unittest.testcase not found on path

24 次查看(过去 30 天)
I received an error message when running the SolverTest example:
Error using SolverTest
The specified superclass 'matlab.unittest.TestCase' contains a parse error, cannot be found on MATLAB's search path, or is shadowed by another file with the same name.
I'm running R2015b on xUbuntu. The folder /usr/local/MATLAB/R2015b/toolbox/matlab/testframework is on the path and the files all seem to be there.I already reinstalled MATLAB.
Any Ideas? Thx, martin

回答(4 个)

Kiran
Kiran 2016-2-12
There could be multiple issue causing this behavior.
1. You may not had executed following command at MATLAB command prompt:
import matlab.unittest.TestSuite
2. There could be another file by name with name TestSuites which is shadowing the original file. To check this, execute following command:
which -all matlab.unittest.TestSuite
This should give output as
C:\Program Files\MATLAB\R2015a\toolbox\matlab\testframework\+matlab\+unittest\TestSuite.m % matlab.unittest.TestSuite constructor
Also, if this file is not on MATLAB path then add it to MATLAB path using method "addpath".
Let me know if doesn't solve the issue.
  4 个评论
Bill Tubbs
Bill Tubbs 2022-6-15
Now I downloaded Matlab R2021b and still get the same error. I will ask a new question.

请先登录,再进行评论。


Andy Campbell
Andy Campbell 2016-2-12
This does seem like an installation problem. A couple things to try:
1. Look for TestCase
>> which -all matlab.unittest.TestCase
matlab.unittest.TestCase is a built-in method % matlab.unittest.TestCase constructor
2. Look for the resulting library. Look for matlab/bin/glnxa64/libmwmatlabunit.so in your installation, as well as matlab/bin/registry/libmwmatlabunit.xml. If they are not there this is a problem with your installation.
  3 个评论
Andy Campbell
Andy Campbell 2016-2-15
编辑:Andy Campbell 2016-2-15
Hmmmm, I'm stumped, everything looks fine as far as I can tell. I would suggest connecting with our installation support team, they should be able to help you get to the bottom of these problems.
Martin
Martin 2016-2-16
yes thx, meanwhile I uninstalled R2015b and went back to R2015aSP1 - now everything works fine. Maybe I will try again with the next release.

请先登录,再进行评论。


Marcelo
Marcelo 2017-11-1
I am with this same problem.
I tried to execute the example "TestCarpet" described in https://www.mathworks.com/help/matlab/matlab_prog/create-basic-parameterized-test.html and also in the "Create Basic Parameterized Test" section within Help, but I received always the same error:
>> suite = matlab.unittest.TestSuite.fromFile('TestCarpet.m');
Error using matlab.unittest.TestSuite.fromFile (line 159)
The specified superclass 'matlab.unittest.TestCase' contains a parse error, cannot be found on MATLAB's search path, or is shadowed by another file with the same name.
Like Martin, I am using Matlab R2015b 32-bits, but the Windows version.
Is there some incompatibility between the Unit Test Framework and the 2015b release?
I looked for in Bug Reports, but I did not find anything about this particular problem.
Debugging the code it was possible to see that the problem occurred during the calling
suite = factory.createSuiteExplicitly(selector);
inside TestSuite class definition file.
Thanks
Marcelo

Benoît Bourassa-Moreau
编辑:Benoît Bourassa-Moreau 2019-6-11
I have the same error prompt as Martin but on Matlab R2016a (9.0.0.341360) win64. I've been working with Test objects for the past few months without any issues and previously working Test Case stopped working this morning. I'm able to find TestSuite, but not TestCase in my path:
>> which -all matlab.unittest.TestSuite
C:\Program Files\MATLAB\R2016a\toolbox\matlab\testframework\core\+matlab\+unittest\TestSuite.m % matlab.unittest.TestSuite constructor
And
>> which -all matlab.unittest.TestCase
'matlab.unittest.TestCase' not found.
I've tried to restore my Matlab path and rehash the Matlab root functions and class:
>> restoredefaultpath
>> rehash toolboxcache
TestCase still cannot be found.
Thank you,
Benoit

类别

Help CenterFile Exchange 中查找有关 Entering Commands 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by