[英]Android black-box testing (no access to app code). Is Google's Espresso a good choice?
[英]Android Espresso black-box testing
是否有人尝试使用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
谢谢!
浓缩咖啡只能作为仪器测试的一部分运行。 仪表测试只能对被测应用(即仪表的目标)起作用。
UIAutomator可能更适合您的用例。
https://developer.android.com/tools/testing-support-library/index.html#UIAutomator
在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 gray-box testing
。
如果您不熟悉Java或Android编程,或者只想以最清晰的方式编写black-box testing
,请尝试学习而不是使用Espresso
这个框架
Calabash-iOS
和Calabash-Android
是底层的底层库,可让Cucumber工具在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/
@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测试用例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.