- Testing Accessibility
- Testing UI Performance
- Test Recorder
- Testing UI for Multiple Application
- Testing Intents
- Testing Asynchronous Operations
- Testing WebView
- Testing AdapterView
- View Actions
- View Assertions
- Custom View Matchers
- View Matchers
- Architecture
- Overview of JUnit
- Running Tests In Android Studio
- Setup Instructions
- Introduction
- Espresso Testing - Home
Espresso Testing Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Espresso Testing Framework - View Assertions
正如前面所讨论的那样,观点主张既要坚持实际观点(利用观点对等)又要说同样的看法。 样本代码如下:
onView(withId(R.id.my_view)) .check(matches(withText("Hello")))
这里
onView( <Interation, 表示与这一观点相符的物体。 ViewInteraction 采用对应观点进行互动。
withId(R.id.my_view) 浏览量等于id属性等于my_view。
T withextHello> 还将收到一种与(预期)案文属性等于Hello的观点相匹配的观点。
check是接受ViewAssertion论点并使用ViewAssertion标本的表述方法。
matches(withTextHello”) 退回一种观点主张,即实际观点(见with Id)和预期观点(见with Text)相同。
让我们学习抑制试验框架提供的一些方法,以表明对物体的看法。
doesNotExist()
一种观点主张,即确保观点匹配者不发现任何相匹配的观点。
onView(withText("Hello")) .check(doesNotExist());
这里 the test case ensures that there is no view with text Hello.
matches()
接受目标观点匹配者,并回复观点主张,确保观点匹配者(实际)存在,与目标观察者匹配。
onView(withId(R.id.textView_hello)) .check(matches(withText("Hello World!")));
这里 the test case ensures that the view having id, R.id.textView_hello exists and matches with the target view with text Hello World!
isBottomApgnedWith()
接受目标观点匹配者,并退回观点主张,以确保观点匹配者(实际)存在,并且与目标观察者匹配。
onView(withId(R.id.view)) .check(isBottomApgnedWith(withId(R.id.target_view)))
这里 the test case ensures that the view having id, R.id.view exists and is bottom apgned with view having id, R.id.target_view.
isCompletelyAbove()
接受目标观点匹配者,并退回观点主张,确保观点匹配者(实际)存在,完全高于目标观察者。
onView(withId(R.id.view)) .check(isCompletelyAbove(withId(R.id.target_view)))
这里 the test case ensures that the view having id, R.id.view exists and is positioned completely above the view having id, R.id.target_view
isCompletelyBelow()
接受目标观点匹配者,并退回观点主张,确保观点匹配者(实际)存在,完全低于目标观察者。
onView(withId(R.id.view)) .check(isCompletelyBelow(withId(R.id.target_view)))
这里 the test case ensures that the view having id, R.id.view exists and is positioned completely below the view having id, R.id.target_view.
isCompletelyLeftOf()
接受目标观点匹配者,并退回观点主张,确保观点匹配者(实际)存在,完全脱离目标观点匹配者。
onView(withId(R.id.view)) .check(isCompletelyLeftOf(withId(R.id.target_view)))
这里 the test case ensures that the view having id, R.id.view exists and is positioned completely left of view having id, R.id.target_view
isCompletelyRightOf()
接受目标观点匹配者,并退回观点主张,以确保观点匹配者(实际)的存在,并完全享有目标观点匹配者的权利。
onView(withId(R.id.view)) .check(isCompletelyRightOf(withId(R.id.target_view)))
这里 the test case ensures that the view having id, R.id.view exists and is positioned completely right of the view having id, R.id.target_view.
isLeftApgnedWith()
接受目标观点匹配者,并退回观点主张,确保观点匹配者(实际)存在,并与目标观点匹配者保持一致。
onView(withId(R.id.view)) .check(isLeftApgnedWith(withId(R.id.target_view)))
这里 the test case ensures that the view having id, R.id.view exists and is left apgned with view having id, R.id.target_view
isPartiallyAbove()
接受目标观点匹配者,并回复观点主张,确保观点匹配者(实际)存在,其地位部分高于目标观察者。
onView(withId(R.id.view)) .check(isPartiallyAbove(withId(R.id.target_view)))
这里 the test case ensures that the view having id, R.id.view exists and is positioned partially above the view having id, R.id.target_view
isPartiallyBelow()
接受目标观点匹配者,并退回观点主张,以确保观点匹配者(实际)的存在,并部分低于目标观点匹配者。
onView(withId(R.id.view)) .check(isPartiallyBelow(withId(R.id.target_view)))
这里 the test case ensures that the view having id, R.id.view exists and is positioned partially below the view having id, R.id.target_view.
isPartiallyLeftOf()
接受目标观点匹配者,并退回观点主张,确保观点匹配者(实际)存在,并且被部分置于目标观点匹配者的位置。
onView(withId(R.id.view)) .check(isPartiallyLeftOf(withId(R.id.target_view)))
这里 the test case ensures that the view having id, R.id.view exists and is positioned partially left of view having id, R.id.target_view.
isPartiallyRightOf()
接受目标观点匹配者,并退回观点主张,确保观点匹配者(实际)存在,并部分享有目标观点匹配者的权利。
onView(withId(R.id.view)) .check(isPartiallyRightOf(withId(R.id.target_view)))
这里 the test case ensures that the view having id, R.id.view exists and is positioned partially right of view having id, R.id.target_view.
isRightApgnedWith()
接受目标观点匹配者,并回归观点主张,确保观点匹配者(实际)存在,与目标观点匹配者保持适当一致。
onView(withId(R.id.view)) .check(isRightApgnedWith(withId(R.id.target_view)))
这里 the test case ensures that the view having id, R.id.view exists and is right apgned with view having id, R.id.target_view.
isTopApgnedWith()
接受目标观点匹配者,并退回观点主张,确保观点匹配者(实际)存在,与目标观点匹配者保持高度一致。
onView(withId(R.id.view)) .check(isTopApgnedWith(withId(R.id.target_view)))
这里 the test case ensures that the view having id, R.id.view exists and is top apgned with view having id, R.id.target_view
noElppsizedText()
一种观点主张,即确保观点等级不包含略微或贬低案文观点。
onView(withId(R.id.view)) .check(noElppsizedText());
noMultipneButtons()
一种观点主张,即确保观点等级不包含多线纽扣。
onView(withId(R.id.view)) .check(noMultipneButtons());
noOverlaps()
一种观点主张,即确保可判读书的后代不相互重叠。 它有另一种选择,接受目标观点匹配者,并回归观点主张,确保后代认为与目标观点相匹配不会重叠。
Advertisements