Tag: 浓缩咖啡

@BeforeClass和@AfterClass在每次测试之前和之后调用

我有一个非常简单的测试类,用于在Android上运行espresso测试,如下所示: import android.util.Log; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.ExternalResource; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import java.io.IOException; @RunWith(JUnit4.class) public class Wtf { private static class TestResources extends ExternalResource { protected void before() { println(“before() TestResources”); } protected void after() { println(“after() TestResources”); } } @ClassRule public static final TestResources […]

Espresso onData在视图上执行“加载适配器数据”时出错

我有一个应用程序,有ListView,我想找到LinearLayout,id = order_untake_jijia_listview_jia 代码是: onData(withClassName(endsWith(“ListView”))) .inAdapterView(allOf(withId(R.id.order_untake_jijia_listview_ll), hasSibling(withText(“9.0”)))) .atPosition(0).onChildView(withId(R.id.order_untake_jijia_listview_jia)); dataInteraction.perform(ViewActions.click()); 但我有错误: Error performing ‘load adapter data’ on view ‘(with id: com.edaixi:id/order_untake_jijia_listview_ll and has sibling: with text: is “9.0”)’. Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints: (is assignable from class: class android.widget.AdapterView […]

预validation类中的Android错误类ref解析为意外实现

我在Android Espresso测试中遇到过这个问题。 但是这在运行/编译时运行良好。 我知道这个错误有几个线程,但我找不到符合我情况的修复程序。 我目前正在处理一个 “java.lang.IllegalAccessError:预validation类中的类ref解析为意外实现”。 我已经添加了 androidTestCompile(‘com.android.support.test.espresso:espresso-contrib:2.2’) { exclude group: ‘com.android.support’, module: ‘support-v4’ } 但它仍然无法正常工作。 有人可以帮我解决这个问题。 谢谢。 这是我的依赖 dependencies { compile fileTree(dir: ‘libs’, include: [‘*.jar’]) /*Android Testing*/ androidTestCompile ‘com.android.support.test:runner:0.3’ androidTestCompile ‘com.android.support.test:rules:0.3’ androidTestCompile ‘com.android.support.test.espresso:espresso-core:2.2’ androidTestCompile ‘com.android.support.test.espresso:espresso-idling-resource:2.2.1’ androidTestCompile ‘com.android.support:support-annotations:23.0.1’ androidTestCompile(‘com.android.support.test.espresso:espresso-contrib:2.2’) { exclude group: ‘com.android.support’, module: ‘support-v4’ } compile ‘com.google.android.gms:play-services:8.3.0’ compile ‘com.android.support:support-v4:23.0.+’ compile ‘com.android.support:appcompat-v7:23.0.1’ compile ‘com.mcxiaoke.volley:library:1.0.18’ compile […]