Conversation
han8129
left a comment
There was a problem hiding this comment.
Anh sẽ kiểm tra hàm getLeastNode, do mình đang làm với TwoSet nên kiểm tra Triplet chưa có tác dụng gì
| assertTrue(matches.getSetOf(6).contains(5)); | ||
| } | ||
|
|
||
| @Test |
There was a problem hiding this comment.
nên sử dụng ParametizedTest để đảm bảo range của input
| assertFalse(matchedSet.contains(8)); | ||
| } | ||
|
|
||
| @Test |
There was a problem hiding this comment.
nên sử dụng ParametizedTest để đảm bảo input đa dạng
han8129
left a comment
There was a problem hiding this comment.
thêm input cho các case để có từ 5..7 input cho mỗi cái. Sửa lại logic ktra both way để không phụ thuộc vào class Matches
| Matches matches = new Matches(5); | ||
| matches.addMatchBi(node1, node2); | ||
|
|
||
| assertTrue(matches.isMatched(node1, node2), "Node1 and Node2 should be matched both ways"); |
There was a problem hiding this comment.
khi kiểm tra tránh để logic của mình bị phụ thuộc vào method của class bị kiểm tra. Cần phải tự lấy ra match của mỗi index và ktra
han8129
left a comment
There was a problem hiding this comment.
xem xét lại testSelectNewMatch chỉ cần ktra getLeastNode thôi nhé
| // 1. Select New Match | ||
| @ParameterizedTest | ||
| @CsvSource({ | ||
| "0,1,2,1", | ||
| "1,2,3,2", | ||
| "2,3,4,3", | ||
| "3,4,5,4", | ||
| "4,5,6,5", | ||
| "5,6,7,6", | ||
| "6,7,8,7" | ||
| }) | ||
| void testSelectNewMatch(int targetIndividual, int newIndividual, int leastPreferred, int expected) { | ||
| Matches matches = new Matches(10); | ||
| matches.addMatch(targetIndividual, leastPreferred); | ||
| matches.addMatch(targetIndividual, newIndividual); | ||
|
|
||
| Set<Integer> currentMatches = matches.getSetOf(targetIndividual); | ||
| currentMatches.add(newIndividual); | ||
|
|
||
| Integer result = Collections.min(currentMatches); | ||
| assertEquals(expected, result, "The least preferred individual should be " + expected); | ||
| } |
There was a problem hiding this comment.
cái này đâu có tác dụng gì đâu nhỉ?
| "0,5,6,7,8,6", | ||
| "0,5,7,8,9,7" | ||
| }) | ||
| void testGetLeastNode(int set, int newNode, int node1, int node2, int node3, int expected) { |
There was a problem hiding this comment.
có thể thay CsvSource bằng MethodSource nhé em
* unit test matching * unit test matching2 * unit test matching3 * unit test matching4 * unit test matching5
No description provided.