How does pairwise parameterization work in the unit test framework?
Show older comments
I have studied the example script in the documentation, but I can't see how the test parameters are being chosen in "pairwise" fashion. Why is the number of combinations 10 in this example? What is the algorithm to generate pairwise parameters?
3 Comments
Siriniharika Katukam
on 7 Aug 2019
Can you provide the link of the example you have referred to?
Brett Pantalone
on 9 Aug 2019
Greg
on 28 Apr 2020
8 months later and nothing on this? The documentation is extremely minimal on this, which is surprising and disappointing considering how thorough MATLAB documentation typically is. I would ask the additional question of what "pairwise" even means given the example has 3 input parameters - a group of 3 is not called a pair.
Accepted Answer
More Answers (2)
Alex Kashuba
on 27 Jan 2021
I think the answer is following. Let say we have parameters
classdef PairwiseTest < matlab.unittest.TestCase
properties (TestParameter)
a = { '1', '2', '3', '4', '5'}
b = { '1', '2', '3', '4', '5'}
c = { '6', '7', '8'}
d = { '0', '9'}
end
methods(Test, ParameterCombination='pairwise')
function testPairwise(tc, a, b, c, d)
fprintf(['\n' a b c d ])
end
end
methods(Test, ParameterCombination='exhaustive')
function testPairAC(tc, a, c)
fprintf(['\n' a '_' c '_' ])
end
end
end
We get here for testPairwise
1160.
1279.
1380.
1469.
1560.
2170.
2260.
2369.
2480.
2579.
3189.
3260.
3379.
3470.
3589.
4160.
4289.
4370.
4479.
4580.
5160.
5279.
5389.
5460.
5579.
The run gives us such combinations that any pair of parameters (say a and c, but can be any other) are exhaustive i.e. all combitations of testPairAC are included:
1_6_.
1_7_.
1_8_.
2_6_.
2_7_.
2_8_.
3_6_.
3_7_.
3_8_.
4_6_.
4_7_.
4_8_.
5_6_.
5_7_.
5_8_.
1 Comment
Ashley Trowell
on 18 Jul 2022
Well this is a very direct way to get to the answer.
Houman Rastegarfar
on 7 Mar 2023
0 votes
The documentation now provides more information about pairwise parameter combination. For details, see https://www.mathworks.com/help/matlab/matlab_prog/use-parameters-in-class-based-tests.html#mw_292dd6d4-5538-4bcc-9ab8-70cd798333bd
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!