Tutorial 10: Best Practices To Test Android Application Using TestComplete

We write automation test scripts for Android application in TestComplete to build a test suite. But do you know that your test scripts are optimized? Are you sure that you have maximum test coverage with the automation scripts which you have prepared? Also, are you confident that there are no duplicate test scripts and you have followed the best-recommended practices to test with an Android application using TestComplete?

Well, I have compiled this article keeping in mind that what we are developing as test automation scripts using TestComplete are optimized, test cases have maximum test coverage, no test script is duplicated and everywhere we are going to follow best practices for which I have recommendations in this article. Below, we are going to cover some of the best practices to test an android application using a TestComplete tool. Following these practices will not only help you in better test results but also, it will make your set up and testing easier.

Best Practices using TestComplete

1) Prepare Test cases with maximum Test Coverage:

As a rule of thumb, our test cases should be concrete, written in the simple manner which covers maximum test coverage. If we are performing data-driven testing then we should be mindful in providing the required test data in test storage such as it is covering all the scenarios. For example, if we have to test the age field then we should choose test data that covers the boundary values i.e. age cannot be negative, it cannot exceed 3 digits, and it will always be number. Therefore, we have to just prepare test data in data storage with these 3 details and it will provide 100% test coverage.

 

2) Use Traceability Matrix:

Traceability matrix is a row and column relationship where rows have the test cases and columns have the requirement test scenarios. At the intersection point, we can conclude which test case is covering which requirement. With this approach of traceability matrix, we can easily identify which test case is getting duplicated or uncovered at all. Therefore, we are not only eliminating the duplication of test cases but all ensuring that at lease each test scenarios is covered at least once (maximum test coverage).

 

3) Test scripts Optimization:

We should make sure while writing test scripts that they are not very verbose, there is no dead code and meet the agreed coding standards. A test scripts developer is required to be very careful while working with test data loops in order to ensure that the loop end condition is appropriately met and it is not going into infinite loop. Also, the test scripts should follow indentations and code level comments so that they are readable to test scripts reviewer and are very easy to maintain and update in future execution of these test scripts.

 

4) Never run TestComplete and TestExecute:

It is advisable that we should be running TestComplete and TestExecute at the same time on your machine (in the same window session or different) since these two android test engines will conflict and produce unexpected results. To avoid this, either run them separately or one after the other.

 

5) TestComplete Interaction:

Whether you have prepared your application for testing would determine how TestComplete interacts with it. For white-box app or open app, a tester can access the methods, fields, and properties and for a black-box app, image-based tests are created. Images can be saved in image repository as shown in the figure below. Choosing the right method to test your app would result in accurate scripts and hence, accurate test results.

Img_repo

 

6) Record Test Script before using Descriptive Programming:

It is always a good idea to record a test script before using the descriptive programming to enhance it. This way you will get a skeleton code to work on and would not have to write everything from scratch. This saves a lot of coding time. When you perform some actions against the tested android application by recording them then TestComplete automatically recognizes all these actions and convert them to a test script. This is especially useful for those who don`t have a lot of experience.

 

7) Keep Help notes Handy:

One of the best practices while recording a test is to keep the help notes handy. Do not switch to TestComplete help while recording is on since TestComplete records every user action and will capture the switching to help section as well.

Record_test

 

8) Carefully operate Pointer devices such as Mouse, etc.:

During the test execution, it is advisable that tester should not move the mouse or press any key since it can interfere with the running test actions which will produce unexpected behavior. Leave the screen as is while running the test for accurate results.

 

9) Regular housekeeping of testing Logs:

After each test execution cycle, results are stored in the form of log files which can consume a lot of memory when tests are run repeatedly. To avoid this, tester either can delete the log files manually or limit the number of log files created. This log file has all the actions listed with the time stamp of an action completed.

 

10) Check all pre-conditions are met:

Before running a recorded android test, you should make sure that all the preconditions are met. If this practice is not followed then the test might fail. For example, say the app was already running when you recorded the test but when you are executing the recorded test, you closed down the app and tried to run the same test on it. It would fail since the script will expect the app to be running.

 

11) Running tests on multiple devices:

To run one test on multiple devices, it is very important to prepare that device for test execution. You can do that by enabling developer options and connecting the device through USB. Always make sure that device setting “Stay Awake” is enabled for smooth test execution.

 

Conclusion

In this article, we discussed the best practices to test Android application using TestComplete.


If you missed any article in TestComplete Tutorial Series then not to worry. Check out all articles list here.

⇓ Complete TestComplete Tutorial Series ⇓

Happy Testing!!

Leave a Comment

Share This Post