首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android Espresso黑盒测试

Android Espresso黑盒测试
EN

Stack Overflow用户
提问于 2015-07-21 11:06:45
回答 3查看 2.4K关注 0票数 1

有没有人尝试过用Android Espressoblack-box testing

谁能给我举个简单的例子?

我以前试过一些例子,但每次都失败了!

举个例子,我试过这个:

代码语言:javascript
复制
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说:

代码语言:javascript
复制
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

谢谢!

EN

回答 3

Stack Overflow用户

发布于 2015-08-03 05:32:31

Espresso只能作为指令插入测试的一部分运行。检测测试只能作用于被测应用程序(即检测的目标)。

UIAutomator可能更适合您的用例。

https://developer.android.com/tools/testing-support-library/index.html#UIAutomator

票数 1
EN

Stack Overflow用户

发布于 2015-12-14 16:04:52

Espresso文档中,您会发现下面这一行:

代码语言:javascript
复制
 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-iOSCalabash-Android是底层的低级库,支持黄瓜工具在安卓上运行自动化功能测试……

网址:https://calaba.sh/

GitHub:https://github.com/calabash

在这里,您将了解如何以及为什么开始使用这个框架:http://blog.teddyhyde.com/2013/11/04/a-better-way-to-test-android-applications-using-calabash/

票数 0
EN

Stack Overflow用户

发布于 2016-02-26 17:45:05

代码语言:javascript
复制
@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测试用例的详细信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31529686

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档