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.
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.
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.
Robotium Test cases can be executed in the Android emulator as well as the Android real device.
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!
XML report generation is quite simple when we are using Eclipse IDE
Steps to be followed
Run the Junit test as usual in eclipse Run As->Android Junit Test.
Once the test run is completed you will be indicated with the status in the status bar provided by the IDE.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With