Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for settings and sortingAndGrouping module #12

Merged
merged 12 commits into from
Jul 23, 2019

Conversation

GOVINDDIXIT
Copy link
Owner

@GOVINDDIXIT GOVINDDIXIT commented Jul 4, 2019

This PR is specific to GSoC'19 project (Improve test automation in Rocket.Chat Android Repo)

Change Log

  • Add UI Automator for cross-app functional UI testing
  • Add Unit tests for the settings module
  • Add UI test for the settings module
  • Add UI test for sortingAndGrouping module
  • Remove run UI test script from CircleCi

Current Code coverage: 35% by Instructions 19% by branch

@codecov
Copy link

codecov bot commented Jul 4, 2019

Codecov Report

Merging #12 into develop will increase coverage by 0.16%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             develop     #12      +/-   ##
============================================
+ Coverage       0.51%   0.67%   +0.16%     
- Complexity        25      32       +7     
============================================
  Files            321     321              
  Lines          10456   10456              
  Branches        1821    1821              
============================================
+ Hits              54      71      +17     
+ Misses         10382   10364      -18     
- Partials          20      21       +1
Impacted Files Coverage Δ Complexity Δ
app/src/main/java/testConfig/Config.kt 0% <ø> (ø) 0 <0> (ø) ⬇️
...android/settings/presentation/SettingsPresenter.kt 24.28% <0%> (+24.28%) 7% <0%> (+7%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 872f900...0cc0eee. Read the comment docs.

@@ -34,10 +34,10 @@ class MembersFragmentTest {
@Before
fun setUp() {
try {
login_if_user_is_logged_out()
navigate_to_channel_details()
loginIfUserIsLoggedOut()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you counting on this to throw an exception if the user is already logged in? Is that safe? Is it guaranteed that no other exception could be thrown? I just wonder if there is a more positive test whether the user is logged in...

Copy link
Owner Author

@GOVINDDIXIT GOVINDDIXIT Jul 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here is that if the user is already logged in then there will be a NoMatchingViewException which will be caught and for which we have to do nothing just proceed further in this case navigateToChannelDetails but if the user is not logged in then we have to make the user login first then navigate further

Copy link
Owner Author

@GOVINDDIXIT GOVINDDIXIT Jul 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to place this logic in some tests because the tests should be independent of each other (best practices) Also it saves tests from failing, there can be a case in which a test which tests a scenario after user authentication is performed before the actual login of the app as the there is no predefined order in which test run. So, in that case, it will perform login first and then test the required thing

@GOVINDDIXIT GOVINDDIXIT changed the title Add tests for settings module Add tests for settings and sortingAndGrouping module Jul 12, 2019
@ear-dev
Copy link
Collaborator

ear-dev commented Jul 16, 2019

Govind...... I tested the latest, and all tests passed except the two appStore tests. I'm pretty sure that is because the appStore does not recognize my emulator as a compatible device for the RocketChat app, so it does not offer the "rate" and "feedback" options. Have you seen this issue? I have tried to debug, but still have no idea what might be missing.

I am inclined to approve this PR, but first, can you point me to the code you added that protected other tests from failing in the case of a test failure? I'm curious...... thanks.

@GOVINDDIXIT
Copy link
Owner Author

Govind...... I tested the latest, and all tests passed except the two appStore tests. I'm pretty sure that is because the appStore does not recognize my emulator as a compatible device for the RocketChat app, so it does not offer the "rate" and "feedback" options. Have you seen this issue? I have tried to debug, but still have no idea what might be missing.

I am inclined to approve this PR, but first, can you point me to the code you added that protected other tests from failing in the case of a test failure? I'm curious...... thanks.

Thanks @ear-dev. Yes, the compatibility issue of the emulator seems to be the cause of the failure at first look. But when I dig into it I found that in some cases the intent to open the Gmail and play store is taking more time than expected. Since I am checking whether the Rocket.Chat text is present in the display screen when the play store opens up. It fails when it takes more time to open the play store app, same is with the Gmail app. I also have an incompatible emulator Still the tests are passing 8/10 times failing 2 times because of intent taking more time. As discussed I will unit test these two test cases.

@GOVINDDIXIT
Copy link
Owner Author

GOVINDDIXIT commented Jul 16, 2019

I am inclined to approve this PR, but first, can you point me to the code you added that protected other tests from failing in the case of a test failure? I'm curious...... thanks.

previously tests were failing because the instance of play store and Gmail already open causing UI hindrance to other tests. Earlier I was using pressBack() which is a method from Espresso to press back button, But I should use mDevice.pressBack() because we are using UI Automator here which is used to test interaction outside the app or bw multi apps. So mDevice.pressBack() works in this case and now these instances of open apps(play store and gmail) will not affect our test flow.

@GOVINDDIXIT GOVINDDIXIT requested a review from ear-dev July 21, 2019 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants