In previous post, it focuses on the white-box testing using Espresso. In this post, I’m going to do Black-box test using Robotium.
What is Black-box Testing?
Black-box testing is a method of the software testing that examines the functionality of an application without peering into its internal structure. For example, in a black-box test on Android application, the tester only knows the inputs and what the expected outcomes should be and not how the program arrives at those outputs.
Demonstration of the Black-box testing
This test focuses on these three main areas: grid view, view pager and navigation drawer. The process of the testing the functionalities is exactly same as the previous post.
Here is the demonstration of test:
Coding
The code is simpler than white-box test using Espresso because it mainly focuses on the input and expected outcomes. Therefore, this test can be done without any knowledge on the codebase of targeted Android application.
publicvoidtestGridView()throwsException{//Close the dialog and press later buttonsolo.clickOnButton("Later");//Scroll the 3rd image of view and select itsolo.scrollListToLine(0,3);solo.clickInList(0);solo.sleep(1000);//Do the swipingsolo.scrollToSide(Solo.RIGHT);//Back to the main screensolo.goBack();//Scroll the 5th image of view and select itsolo.scrollListToLine(0,5);solo.clickInList(0);solo.sleep(2000);//Do the swipingsolo.scrollToSide(Solo.RIGHT);solo.sleep(1000);solo.scrollToSide(Solo.RIGHT);solo.sleep(1000);solo.scrollToSide(Solo.LEFT);//Back to main screensolo.goBack();}publicvoidtestNavigationDrawer()throwsException{//Click on the later buttonsolo.clickOnButton("Later");//Open and close the drawersolo.clickOnActionBarHomeButton();solo.sleep(2000);solo.clickOnActionBarHomeButton();solo.sleep(2000);//Open the drawer and select dog categorysolo.clickOnActionBarHomeButton();solo.sleep(2000);solo.clickOnText("Flickr: Dogs");solo.sleep(2000);//Open the drawer again and select tutorialsolo.clickOnActionBarHomeButton();solo.sleep(2000);solo.drag(300,300,1000,300,2);solo.clickOnText("Tutorial");solo.sleep(1500);//Do the swiping on tutorial screensolo.scrollToSide(Solo.RIGHT);solo.sleep(1000);solo.scrollToSide(Solo.RIGHT);solo.sleep(1000);solo.scrollToSide(Solo.LEFT);//Back to previous activitysolo.goBack();solo.sleep(1500);}