有没有人尝试过用Android Espresso做black-box testing
谁能给我举个简单的例子?
我以前试过一些例子,但每次都失败了!
举个例子,我试过这个:
public class ApplicationTest extends ActivityInstrumentationTestCase2
{
private static final String ACTIVITY_CLASSNAME = "com.example.kai_yu.blackboxtest";
private static Class launchActivityClass;
static
{
try
{
launchActivityClass = Class.forName(ACTIVITY_CLASSNAME);
}
catch (ClassNotFoundException e)
{
throw new RuntimeException(e);
}
}
public ApplicationTest()
{
super(launchActivityClass);
}
@Test
public void testClick()
{
}}
但Android Studio说:
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.kai_yu.blackboxtest"
com.example.kai_yu.blackboxtest is applicationId which is another installed application on my phone谢谢!
发布于 2015-08-03 05:32:31
Espresso只能作为指令插入测试的一部分运行。检测测试只能作用于被测应用程序(即检测的目标)。
UIAutomator可能更适合您的用例。
https://developer.android.com/tools/testing-support-library/index.html#UIAutomator
发布于 2015-12-14 16:04:52
在Espresso文档中,您会发现下面这一行:
While it can be used for black-box testing, Espresso's full power is unlocked by those who are familiar with the code base under test."出于这个原因,gray-box testing调用了Espresso测试。
如果您不熟悉Java或Android编程,或者只想以最清晰的方式编写black-box testing,请尝试学习而不是Espresso这个框架
Calabash-iOS和Calabash-Android是底层的低级库,支持黄瓜工具在安卓上运行自动化功能测试……
GitHub:https://github.com/calabash
在这里,您将了解如何以及为什么开始使用这个框架:http://blog.teddyhyde.com/2013/11/04/a-better-way-to-test-android-applications-using-calabash/
发布于 2016-02-26 17:45:05
@RunWith(AndroidJUnit4.class)
@LargeTest
public class EspressoTest1 extends ActivityInstrumentationTestCase2<MainActivity>{
public EspressoTest1() {
super(MainActivity.class);
}
@Before
public void setUp() throws Exception {
super.setUp();
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
}
@Test
public void test1ChatId() {
getActivity();
onView(withId(R.id.anuja)).check(matches(isDisplayed()));
}
@After public void tearDown() throws Exception {
super.tearDown();
}
}有两种方法可以编写Espresso测试用例,一种是如上所示,示例取自此博客http://qaautomated.blogspot.in/p/blog-page.html
在那里您可以找到运行espresso测试用例的详细信息。
https://stackoverflow.com/questions/31529686
复制相似问题