TextInputLayoutAssertions methods has false-positive behaviour
timofei-malygin opened this issue · comments
Timofei Malygin commented
Steps to reproduce:
- Create an XML file with TextInputEditText and add tags for TextInputEditText (
tagTextInputEditText
) and for EditText inside the TextInputEditText (tagEditText
). add to Hint any text (e.x. "hint") - create a UI test running the activity with this XML.
- add this code
KTextInputLayout { withTag(tagEditText) }.hasHint("any text _"+ UUID.randomUUID())
Observed Results:
The Test will pass
Expected Result
The Test should fail!
Expected an AssertionError
that EditText is not TextInputLayout
Relevant Code:
The problem is that methods check instances and do not throw an exception if it is different than expected
fun hasHint(hint: String) {
view.check(ViewAssertion { view, notFoundException ->
if (view is TextInputLayout) {
if (hint != view.hint.toString()) {
throw AssertionError(
"Expected hint is $hint," +
" but actual is ${view.hint}"
)
}
} else {
notFoundException?.let { throw AssertionError(it) } // here code should throw AssertionError("expected TextInputLayout, but got $view") if notFoundException is null
}
})
// code here