Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate test result report using robotium?

I have been using robotium to test my android application.Testing was successful but i want to know that is there any way to view test results in a separate file.

like image 817
user594720 Avatar asked Jan 31 '11 12:01

user594720


People also ask

How do you use Robotium?

Test an App with RobotiumStep 1 − Create a test Project in the Android Studio named as “RobotiumTest”. Choose all the default options until you reach to the main page. Step 2 − Copy the Robotium jar file into the Lib folder of the project. Step 3 − Add the dependency in build.

What is Robotium testing tool?

Robotium is an open-source test framework for writing automatic gray box testing cases for Android applications. With the support of Robotium, test case developers can write function, system and acceptance test scenarios, spanning multiple Android activities.

Where can we execute Robotium test cases?

Robotium Test cases can be executed in the Android emulator as well as the Android real device.


3 Answers

I have had good luck just running the robotium tests as regular Android JUnit tests, and then using the standard mechanism to get back the test results, namely the ant task fetch-test-report. To do this I used the build.xml file create by android through the tooling. See documentation for developing in other IDEs for detailed instructions on setting that up. Good luck!

like image 127
Micah Hainline Avatar answered Nov 03 '22 00:11

Micah Hainline


XML report generation is quite simple when we are using Eclipse IDE

Steps to be followed

  1. Run the Junit test as usual in eclipse Run As->Android Junit Test.

  2. Once the test run is completed you will be indicated with the status in the status bar provided by the IDE.

  3. When you click on the Test Run History Icon which is available in the Junit view of eclipse IDE you will find the Export option through which you can you can export the XML format test.

If you have and problems in finding the icon please watch the below image.

enter image description here

like image 33
Rajesh Avatar answered Nov 02 '22 23:11

Rajesh


I use approach with logcat and android class Log.'severity'(tag, msg) ('severity' can be i-info, d-debug, w-warn, e-error, v-verbose), here is an example of clicking button myView:

String viewName = solo.getString(R.string.myViewName); 
try {
    solo.clickOnView((View) solo.getView(R.id.myView));
    Log.i("Passed", viewName + " works correctly.");
} catch (Exception e) {
    Log.e("Error", viewName + " doesn't work.");
}

Using filters you can filter output by tags and selecting all lines save it in .txt file. All these you can do automatically by writing simple script which will redirect output to file from InstrumentationTestRunner for you.

see also pages: Log class, logcat

like image 41
Gennadiy Ryabkin Avatar answered Nov 03 '22 01:11

Gennadiy Ryabkin