我正在尝试设置Double Espresso,但这可能与此无关.我要做的是使用Gradle在Android Studio中设置项目.
虽然我以前成功使用过Maven,但我对Gradle很新,并且总体上构建工具.尽管经过一个小时的搜索,我找不到一个非常简单的问题的答案.
在杰克沃顿的指示中说
不再惹恼当地的罐子或依赖冲突.用一条线把它拉进去:
androidTestCompile'com.jakewharton.espresso:espresso:1.1-r3'
拉到哪里?我在哪里放/执行该命令来导入项目?在命令提示符下?我把它放在其中一个脚本中吗?
谢谢你的帮助.
我正在使用aws设备场来运行我的android测试,我们正在使用espresso框架.今天有些测试失败了,如果我的测试失败,我想拍摄截图.我已经阅读了您的文档,但找不到任何具体的内容.这是我目前所知道的:
您可以将截图作为Android UI Automator测试的一部分.
要截取屏幕截图,请调用takeScreenshot方法(例如,takeScreenshot("/ sdcard/uiautomator-screenshots/home-screen-1234.png");).
注意:所有屏幕截图都必须存储在
/sdcard/uiautomator-screenshots directory.您必须指定要存储的屏幕截图的完整路径(包括文件名).该takeScreenshot方法仅适用于API级别17及更高级别.对于API级别16,支持UI Automator,但不支持屏幕截图.
有没有什么办法可以配置aws device服务器场来自动截取屏幕截图而无需在测试中调用该功能?是否支持?此外,我找不到任何与屏幕截图相关的命令.如果有人能解释截图所需的步骤,我将非常感激.谢谢
android amazon-web-services android-espresso aws-device-farm
使用 Espresso 可以验证当我们选择特定输入字段时出现哪种类型的软键盘。例如让我们选择手机号码 - EditText 它必须显示数字键盘。我们可以用 Espresso 验证它吗?
LinearLayout (productList) 在运行时动态填充子视图,如下所示:
@ViewById(R.id.ll_products)
LinearLayout productList;
public void createProductList() {
productList.addView(getView(mobilePhone))
productList.addView(getView(internet))
productList.addView(getView(television))
}
public View getView(Product product) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
TextView layout = (LinearLayout) inflater.inflate(R.layout.row_product, null);
TextView productIcon = (TextView) layout.findViewById(R.id.tv_product_row_icon);
productIcon.setText(product.getProductIcon());
productName.setText(product.getName());
}
Run Code Online (Sandbox Code Playgroud)
productList 故意是 LinearLayout,而不是 ListView。
产品列表包含三个产品 - 每个产品都有图标(可能有重复)。
我想记录一个场景,我点击第二个产品的图标。这种情况如何避免 AmbiguousViewMatcherException ?
不幸的是,以下代码不起作用 - 将找到三个 R.id.tv_product_row_icon ...
ViewInteraction appCompatTextView = onView(withId(R.id.tv_product_row_icon));
appCompatTextView.perform(scrollTo(), click());
Run Code Online (Sandbox Code Playgroud)
如何指定要单击的第二个图标?
我有这个弹出窗口。我怎样才能按下退出按钮?
我使用这样的字符串:
onView(withId(android.R.id.button1)).perform((click()));
Run Code Online (Sandbox Code Playgroud)
我正在尝试为 android 应用编写测试。其中有 1Activity和 2 fragments(即FragmentOne和FragmentTwo)通过单击FragmentOne它上的按钮转到FragmentTwo. 我写了同样的测试,我正在使用androidxand navigation architecture。我已阅读此链接和此链接,但没有成功。
这是我当前的代码-
示例仪器测试
@RunWith(JUnit4::class)
class ExampleInstrumentedTest {
@Test
fun checkSecondFrag() {
// Create a mock NavController
val mockNavController = mock(NavController::class.java)
// Create a graphical FragmentScenario for the OneFragment
val oneFragmentScenario = launchFragmentInContainer<OneFragment>()
// Set the NavController property on the fragment
oneFragmentScenario.onFragment { fragment ->
Navigation.setViewNavController(fragment.requireView(), mockNavController)
}
// Verify that performing a click prompts …Run Code Online (Sandbox Code Playgroud) android android-espresso android-architecture-components androidx
我已经通过Android文档中的Test Android Apps进行了测试。Google推出了AndroidX测试,但是我对其含义仍然感到困惑。
我将MVVM Android体系结构组件与ViewModel,LiveData一起使用。
我需要使用Android X Framework的哪些部分?
View(Activity.Fragments)->浓咖啡?
ViewModel(with LiveData)-> RoboElectric吗?
模型-> JUnit还是RoboElectric?
为什么Google仍然使我们对许多库感到困惑,为什么它们不能在同一个Framework(Espresso)下移动所有本地测试,工具测试以及所有内容?