How to use constant property when defining TestParameter in unittest.

4 ビュー (過去 30 日間)
Lukas Lacinak
Lukas Lacinak 2016 年 5 月 26 日
コメント済み: Lukas Lacinak 2016 年 5 月 26 日
A constant class property can be used when defining a content of other class properties (e.g. testConstant1 below).
But when this other property is in the TestParameter property block (e.g. testConstant2) matlab complains that 'The class UnitTestConstantInTestParams has no Constant property or Static method named 'CONST_VALUE''.
classdef UnitTestConstantInTestParams < matlab.unittest.TestCase
properties
testConstant1 = num2cell(1:UnitTestConstantInTestParams.CONST_VALUE);
end
properties (Constant)
CONST_VALUE = 5;
end
properties (TestParameter)
% testConstant2 = num2cell(1:5);
testConstant2 = num2cell(1:UnitTestConstantInTestParams.CONST_VALUE);
end
methods (Test)
function testConstValues1(testCase)
for value = testCase.testConstant1
end
end
function testConstValues2(testCase, testConstant2)
end
end
end
Is this a known and desired behavior?
Tested in 8.6.0.267246 (R2015b).

採用された回答

David Hruska
David Hruska 2016 年 5 月 26 日
This is a bug:
https://www.mathworks.com/support/bugreports/1212962
The bug report mentions Static methods but the same issue applies to Constant properties.
  1 件のコメント
Lukas Lacinak
Lukas Lacinak 2016 年 5 月 26 日
Thanks, that was very helpful, since none of the workarounds I tried worked ;-).

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePie Charts についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by