我正在使用groovy,assertj,junit和gradle。我有一个包含类似断言的测试
assertThat(actualLongList).isEqualTo(expectedLongList)
当我运行gradle test
并且这些列表不相等时,它会生成一个测试报告,但有一个例外
org.junit.ComparisonFailure: expected:<...ent2",
"element3",
"element4",
"element5]"]> but was:<...ent2",
"element4,
"element5",
"element6]"]>
我可以以某种方式配置异常输出格式,以便它完全输出两个列表吗?
org.junit.ComparisonFailure: expected:
<["element1",
"element2",
"element3",
"element3",
"element4",]> but was:,
<["element1",
"element2",
"element4",
"element5",
"element6",]>
答案 0 :(得分:1)
这就是org.junit.ComparisonFailure#getMessage()
的工作方式(参见javadoc)。
如果你想要一个完整的(更好的?)描述,你可以使用containsOnlyElementsOf
(或你认为合适的任何containsXxxElementsOf
),你会得到类似的东西:
java.lang.AssertionError:
Expecting:
<["element1",
"element2",
"element3",
"element4",
"element5",
"element6",
"element7",
"element8",
"element9"]>
to contain only:
<["element1",
"element2",
"element3",
"element4",
"element5",
"element6",
"element7",
"element8",
"element0"]>
elements not found:
<["element0"]>
and elements not expected:
<["element9"]>