Is there an easy way to build a test suite from all tests in a folder containing multiple packages?
9 ビュー (過去 30 日間)
古いコメントを表示
I have a non-package directory, containing several packages. Each package may contain subpackages. The packages have class-based unit tests. I can run all the tests for a given package by calling
runtests('mypackage1', "IncludeSubpackages", true)
Is there an easy way to run all tests for all packages?
If I call
runtests(pwd, "IncludeSubfolders", true, "IncludeSubpackages", true)
No tests are run.
0 件のコメント
採用された回答
Andy Campbell
2019 年 12 月 3 日
編集済み: Andy Campbell
2019 年 12 月 3 日
Hi Brian,
I definitely endorse Sean's suggestion to use projects. That said, this is good feedback since it seems you expected IncludeSubfolders to just work in this case. There are reasons for the current behavior, but we can take this feedback to the development team.
In the meantime, if you don't use Sean;s suggestion of putting it into a project, you should be able to create your suite as follows:
import matlab.unittest.TestSuite;
w = what(pwd);
suiteCell = cellfun(@(p) TestSuite.fromPackage(p, 'IncludingSubpackages',true), w.packages, 'UniformOutput', false)
suite = [suiteCell{:}];
run(suite);
Hope that helps!
その他の回答 (1 件)
Sean de Wolski
2019 年 12 月 2 日
編集済み: Sean de Wolski
2019 年 12 月 2 日
Have you considered adopting projects? I'd recommend it (for most things and especially for this use case) then you can just create the TestSuite from all files in the project.
https://www.mathworks.com/help/releases/R2019b/matlab/ref/matlab.unittest.testsuite.fromproject.html
Otherwise, shy of manually appending multiple TestSuites I don't know a way. My team usually keeps all tests as classes optionally in subppackages of a parent +test package so it's obvious it's a test.
参考
カテゴリ
Help Center および File Exchange で Create and Run MATLAB Tests についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!