Skip to content

Test automation for Rocket.Chat Android Repo

bizzbyster edited this page Jun 25, 2019 · 12 revisions

1. How to successfully run ui-test on circleci

In order to run ui tests for every code change, I have created a new job in our present workflow which will set up the emulator and run the UI tests on it. The tests are running fine locally (real devices/emulator), but having some memory issues when running on circleci.

I have tried all the solutions mentioned online but nothing is working in our case. I had tried around 60+ different memory combinations but again the build is red.
I have also set up the circleci locally on my Linux machine and to the wonder, the build is running fine. Maybe the reason is that it is having 8gb ram and the circleci provides us 4gb of memory on FOSS plan. I have also made the fellow developers aware of the issue but again we have no improvement on it. It will be great if you can suggest some way out or any other option we can have for this task. I am looking for the views of the team what should be done in this case.

[Peter Comment] its important to show the research you've done. Perhaps a link to someone else online who has experienced the issue? And a description of the problem that demonstrates that you have exhausted all possible approaches.

Since the build is not successful online so the coverage reports for the UI tests are also not generated by codecov. So for that, I have created a static site in order to view the reports. It will help in tracking the progress of the project for now. We can switch to codecov reports back once the ui test build become green.
Site: coverage reports

2. How to test private methods

In our presenters we are having three types of methods:

  • Public Coroutines methods
  • Private methods which are used in coroutines methods
  • Public methods which are not using coroutines

We have decided to not to test the coroutines method as the current codebase doesn't support it and require some major refactoring to be done for that. I have already created unit tests for the public methods which are not using coroutines. So now the only problem left is how to test the private methods which are used in coroutine methods.

For this, I have introduced three approaches:

  1. To copy the private methods to the test class and then tests them from there.
  2. To create a new public method for each class which will contain all the private methods of that class and then tests the private methods using it like this.
    fun enablePrivateMethodsForTesting(currentServer: String, userName: String, token: Token) {
        setupConnectionInfo(currentServer)
        saveAccount(userName)
        saveToken(token)
    }
    @Test
    fun check_account_is_saved(){
        loginPresenter.enablePrivateMethodsForTesting(currentServer, userName, token)
        verify(saveAccountInteractor).save(account)
    }

  1. To change the access specifier of private methods and make them public.

Each way has its own impact on code coverage. I am looking for the views of the team on it so that we can choose the best way out of it and also any other option if have missed.