Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextInputLayoutAssertions methods has false-positive behaviour #91

Closed
timofei-malygin opened this issue Jul 12, 2023 · 0 comments · Fixed by #93
Closed

TextInputLayoutAssertions methods has false-positive behaviour #91

timofei-malygin opened this issue Jul 12, 2023 · 0 comments · Fixed by #93
Assignees

Comments

@timofei-malygin
Copy link

timofei-malygin commented Jul 12, 2023

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
@Vacxe Vacxe self-assigned this Jul 13, 2023
Unlimity added a commit that referenced this issue Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants