KakaoCup / Kakao

Nice and simple DSL for Espresso in Kotlin

Home Page:https://kakaocup.github.io/Kakao/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TextInputLayoutAssertions methods has false-positive behaviour

timofei-malygin opened this issue · comments

Steps to reproduce:

  1. 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")
  2. create a UI test running the activity with this XML.
  3. 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