AdevintaSpain / AdevintaSpain/Barista

Tests like *_breaksWhenNeeded are broken

未關閉
#197 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug wip
主要語言
Kotlin
星號
1.7k
分支
119
PR 合併指標
30 天內沒有已合併 PR

描述

There are some tests like `checkEnabledView_breaksWhenNeeded` with code like this:
```java
try {
assertEnabled(R.id.disabled_button);
fail();
} catch (Throwable expected) {
}
```

They're broken because they **always pass**. If `assertEnabled` doesn't fail, `fail()` will be invoked, which launches an `AssertionError`. The funny thing is that the `catch (Throwable expected)` also catches `AssertionError`, so the test will always be green.

It's as easy as changing the catch type to something like `RuntimeException`, which doesn't include `AssertionError`.

貢獻指南

開啟貢獻指南

研究方向

Search the repository for tests named like checkEnabledView_breaksWhenNeeded and for catches of Throwable around assertions. Read the affected Android test files and run their instrumentation tests; done means AssertionError is no longer caught and each test fails when the expected assertion does not fail.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
android, kotlin
領域
mobile, testing
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。