Why are unittests running twice?

5 views (last 30 days)
Reinhold on 9 Jan 2014
Commented: Reinhold on 9 Jan 2014
I'm using the following function on an windows pc and an linux machine for testing my code. Testcases are derived from matlab.unittest.TestCase.
While on Windows it runs all test once, on the linux machine it runs twice. Any idea, what's wrong?
function result = runtests
import matlab.unittest.TestSuite;
suite = TestSuite.fromPackage('tests');
result = run(suite);

Accepted Answer

Andy Campbell
Andy Campbell on 9 Jan 2014
Hi Reinhold,
It's tough to tell precisely what is going on here. My first thought is that perhaps you have two copies of your tests in two separate locations that are both on the path. Try doing the following to see whether there are two packages of the same name showing up on the path:
>> t = what('tests')
If this is a scalar struct then there onlys exists one test package or folder. If it is a struct array with more than one element then it should show you where it is picking up tests from.
What does the suite look like? Does it look expected or are the tests showing up twice in the suite as well?
Also, another thing to look at is whether there is any conflict with the runtests function in MATLAB that is included in the framework (13b and beyond). What happens when you change your function to be named something else, or alternatively, if you just use the included runtests function by typing:
>> result = runtests('tests')
Any information you can provide would be helpful, this certainly doesn't sound like behavior that should be happening.
Does that help?
  1 Comment
Reinhold on 9 Jan 2014
Hi Andy,
thanks a lot, your tip using 'what' was really helpful. It showed a two references to the same folder.
I added the folder of the working path with a shortcut to the path settings. While I'm on the working path it's the full path. That's why I got two references.
Changed now to the path settings to the full path and it runs just once. Thanks again!

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!