[英]Assert.assertAllValuesInArrayAreEqual - unit testing in java using junit, there is no such method?
還是在那里?
我只有
int[] results
並要檢查數組中的每個元素具有相同的int值。
(是的,我可以遍歷它們)。
無需循環,只需將數組轉換為Set對象,然后檢查其長度,如果長度為1,則數組中的所有內容均相等。
Integer[] myArray = ...;
assertThat(new HashSet(Arrays.asList(myArray)).size(), is(1));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.