[英]Android Espresso black-box testing
Does anyone try to do black-box testing
with Android Espresso
? 是否有人尝试使用Android Espresso
black-box testing
?
Could anyone provides me with some simple example? 有人可以给我提供一些简单的例子吗?
I had tried some example before, but failed every time! 我之前曾尝试过一些示例,但每次都失败!
Example, I had tried this one: 例子,我试过这个:
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()
{
}
} }
But Android Studio said: 但是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
Thank you! 谢谢!
Espresso can only run as part of an instrumentation test. 浓缩咖啡只能作为仪器测试的一部分运行。 Instrumentation tests can only act upon the app under test ( ie the target of the instrumentation ). 仪表测试只能对被测应用(即仪表的目标)起作用。
UIAutomator might be better for your use case. UIAutomator可能更适合您的用例。
https://developer.android.com/tools/testing-support-library/index.html#UIAutomator https://developer.android.com/tools/testing-support-library/index.html#UIAutomator
In Espresso
docs you would find this line: 在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."
For that reason Espresso testing is called by gray-box testing
. 因此, gray-box testing
称为Espresso gray-box testing
。
If you're not familiar with programming in Java or Android, or you want just to write black-box testing
in the clearest way as possible try to learn instead of Espresso
this framework 如果您不熟悉Java或Android编程,或者只想以最清晰的方式编写black-box testing
,请尝试学习而不是使用Espresso
这个框架
Calabash-iOS
andCalabash-Android
are the underlying low-level libraries that empower the Cucumber tool to run automated functional tests on Android...Calabash-iOS
和Calabash-Android
是底层的底层库,可让Cucumber工具在Android上运行自动化功能测试...
Website: https://calaba.sh/ 网站: https : //calaba.sh/
GitHub: https://github.com/calabash GitHub: https : //github.com/calabash
Here would you find how and why to start using this framework: http://blog.teddyhyde.com/2013/11/04/a-better-way-to-test-android-applications-using-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();
}
}
There are two ways to write Espresso Test case one is as per shown above The Examples are taken from this blog http://qaautomated.blogspot.in/p/blog-page.html 如上所示,有两种编写Espresso测试用例的方法。示例摘自该博客http://qaautomated.blogspot.in/p/blog-page.html
Where you can find details of hot to run the espresso test case in detail. 在这里可以找到详细信息,详细了解如何运行espresso测试用例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.