我只是触摸单元测试,今天遇到一个非常奇怪的问题,我使用assertThat
来确定两个对象是否相等,
当我测试对象时,有一个测试用例无法通过:
sealed class SummaryViewState : MviViewState {
/**
* 默认显示曲线图和标签汇总状态(首次进入页面)
*/
data class SummaryDataViewState(
val points: List<Pair<Int, Float>>, // 曲线图点
val months: List<Pair<String, Date>>, // 曲线图月份
val values: List<String>, // 曲线图数值文本
val selectedIndex: Int, // 曲线图选中月份索引
val summaryItemList: List<SummaryListItem> // 当月标签汇总列表
) : SummaryViewState()
/**
* 切换月份时标签汇总状态
*/
data class SummaryGroupingTagViewState(
val summaryItemList: List<SummaryListItem> // 当月标签汇总列表
) : SummaryViewState()
}
但看结果是一样的:
java.lang.AssertionError:
Expected: is <[SummaryDataViewState(points=[(0, 100.0), (5, 200.0)], months=[(五月, Mon May 01 22:47:00 CST 2017), (六月, Thu Jun 01 22:47:00 CST 2017), (七月, Sat Jul 01 22:47:00 CST 2017), (八月, Tue Aug 01 22:47:00 CST 2017), (九月, Fri Sep 01 22:47:00 CST 2017), (十月, Sun Oct 01 22:47:00 CST 2017)], values=[¥100.00, ¥200.00], selectedIndex=5, summaryItemList=[SummaryListItem(tagName=晚餐, total=¥200.00)])]>
but: was <[SummaryDataViewState(points=[(0, 100.0), (5, 200.0)], months=[(五月, Mon May 01 22:47:00 CST 2017), (六月, Thu Jun 01 22:47:00 CST 2017), (七月, Sat Jul 01 22:47:00 CST 2017), (八月, Tue Aug 01 22:47:00 CST 2017), (九月, Fri Sep 01 22:47:00 CST 2017), (十月, Sun Oct 01 22:47:00 CST 2017)], values=[¥100.00, ¥200.00], selectedIndex=5, summaryItemList=[SummaryListItem(tagName=晚餐, total=¥200.00)])]>
Expected :is <[SummaryDataViewState(points=[(0, 100.0), (5, 200.0)], months=[(五月, Mon May 01 22:47:00 CST 2017), (六月, Thu Jun 01 22:47:00 CST 2017), (七月, Sat Jul 01 22:47:00 CST 2017), (八月, Tue Aug 01 22:47:00 CST 2017), (九月, Fri Sep 01 22:47:00 CST 2017), (十月, Sun Oct 01 22:47:00 CST 2017)], values=[¥100.00, ¥200.00], selectedIndex=5, summaryItemList=[SummaryListItem(tagName=晚餐, total=¥200.00)])]>
Actual :<[SummaryDataViewState(points=[(0, 100.0), (5, 200.0)], months=[(五月, Mon May 01 22:47:00 CST 2017), (六月, Thu Jun 01 22:47:00 CST 2017), (七月, Sat Jul 01 22:47:00 CST 2017), (八月, Tue Aug 01 22:47:00 CST 2017), (九月, Fri Sep 01 22:47:00 CST 2017), (十月, Sun Oct 01 22:47:00 CST 2017)], values=[¥100.00, ¥200.00], selectedIndex=5, summaryItemList=[SummaryListItem(tagName=晚餐, total=¥200.00)])]>
我在here的考试,有人可以解决这个问题并告诉我这是什么问题吗?