android中单元测试中的断言assert的使用与扩展
首先看一组对比,比如说我们要测试的结果是一个Linearlaout
-
AssertJ Android:
assertThat(layout).isVisible() .isVertical() .hasChildCount(4) .hasShowDividers(SHOW_DIVIDERS_MIDDLE);
-
Regular JUnit:
assertEquals(View.VISIBLE, layout.getVisibility()); assertEquals(VERTICAL, layout.getOrientation()); assertEquals(4, layout.getChildCount()); assertEquals(SHOW_DIVIDERS_MIDDLE, layout.getShowDividers());
-
Regular AssertJ:
assertThat(layout.getVisibility()).isEqualTo(View.VISIBLE); assertThat(layout.getOrientation()).isEqualTo(VERTICAL); assertThat(layout.getChildCount()).isEqualTo(4); assertThat(layout.getShowDividers()).isEqualTo(SHOW_DIVIDERS_MIDDLE);
从输出结果上看,输出结果更加直接可见。
-
AssertJ Android:
Expected visibility <gone> but was <invisible>
. -
Regular JUnit Expected:<[8]> but was:<[4]>
-
Regular AssertJ: Expected: <8> but was: <4>
private String uid ;//发送账号uid,以区别不同账号的草稿
private int type;//保存的类型
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。