Efficient way to determine the outcome of test matrix

て烟熏妆下的殇ゞ 提交于 2019-12-01 13:38:12

问题


Related Questions:

  • Matrix Combination Logic
  • Would cartesian product be the best approach for this

I have 25 validations, each validation returns a boolean ( true it passed, false it failed ).

Each validation can be combined with all other validations to form a Matrix of validation test combinations.

Specific combinations of the sub-set validations will also have pass/fail rules.

Here is a short example:

    V1 | V2 | V3 | V4 | V5
M1:  T |  T |  T |  T |  T   <-- For this Matrix row it would PASS
M2:  F |  T |  T |  F |  T   <-- For this Matrix row it would FAIL  
M3:  F |  F |  T |  T |  T   <-- For this Matrix row it would PASS
M4:  T |  F |  F |  F |  F   <-- For this Matrix row it would PASS
M5:  T |  T |  F |  F |  F   <-- For this Matrix row it would FAIL

I only care about the horizontal validation tests the vertical are for values

I know all the tests and store the outcome of each test in a database. I know all the combination Matrix for the sub-set of all the validation test.

My question is:

What would be the best way to run the Matrix?

Do I store each permutation of each passing or failing test for the Matrix validation? And then where do I store the Matrix combinations?

I'm thinking the only way to do this is to store all the validations combinations for the 25 tests ( yeah 625 entries ) and add the Matrix results I'm expecting for those validations in the same record.

Some something like this

    V1 | V2 | V3 | V4 | V5 | MR ( Matrix Results )
M1:  T |  T |  T |  T |  T | P   <-- For this Matrix row it would PASS
M2:  F |  T |  T |  F |  T | F   <-- For this Matrix row it would FAIL  
M3:  F |  F |  T |  T |  T | P   <-- For this Matrix row it would PASS
M4:  T |  F |  F |  F |  F | P   <-- For this Matrix row it would PASS
M5:  T |  T |  F |  F |  F | F   <-- For this Matrix row it would FAIL

I just feel like there might be a more optimal solution that I'm not seeing, any thoughts?


回答1:


Here is the way I would do it. First define your matrix map in an array:

$map = array( 'TTTTT' => TRUE, 'FTTFT' => FALSE, 'FFTTT' => TRUE );

Obviously there will be more elements in that array, but you get the point. I don't know your table/column names, but next CONCAT v1-v5 and pull as a string. Then, just find that key in the map array:

$sql = "SELECT CONCAT(v1,v2,v3,v4,v5) AS matrix FROM `validation` WHERE `user`= '$user'";
$result = $mysqli->query( $sql );
$user_matrix = array();
while( $row = $result->fetch_assoc() ) $user_matrix[] = $map[ $row['matrix'] ];

Now you have the results in the $user_matrix array



来源:https://stackoverflow.com/questions/13139723/efficient-way-to-determine-the-outcome-of-test-matrix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!