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

Test : Check Snackbar is displayed when the deck is created #16033

Conversation

neeldoshii
Copy link
Contributor

@neeldoshii neeldoshii commented Mar 31, 2024

Purpose / Description

This test checks whether the toast is shown to user after the deck has been created.

Fix

@NeedsTest("Ensure a toast is shown on a successful action")

Note :
I am currently new towards writing test feel free to pin out or recommend the mistakes or advise while testing.

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

We prefer Robolectric (/test/) over /androidTest/ unless there's a good reason

(don't worry about the GSoC deadline regarding testing, we can still talk about it afterwards)

@neeldoshii neeldoshii force-pushed the Test-Ensure-a-toast-is-shown-on-a-successful-action branch from 757d1a8 to 497792b Compare April 2, 2024 20:16
@neeldoshii neeldoshii marked this pull request as draft April 2, 2024 20:16
@neeldoshii neeldoshii marked this pull request as ready for review April 2, 2024 20:52
@neeldoshii
Copy link
Contributor Author

Few Doubts: @david-allison

  1. @NeedsTest("Ensure a toast is shown on a successful action")
    I am not sure is this right or wrong. From what i observed creating a deck or renaming a deck we are showing snackbar not toast. I did wrote the unit test (robolectric) for checking whether it showed toast or not but it was giving me null everytime so i later got to know that we are calling snackbar on successful creation. Just like ShadowToast do we have ShadowSnackbar which does the work?

For now I have just fixed my old instrument test.

@david-allison
Copy link
Member

david-allison commented Apr 3, 2024

If you annotate (git blame), you'll see the @NeedsTest was added in 2022 and you'll see the full context of why we wanted a test

Screenshot 2024-04-03 at 14 02 09


Then look at the history of the class to understand how things have changed over time

See from the git history for the file: be85b46 (ShowSnackbarInsteadOfToast)


The intention of the @NeedsTest is that a user is provided feedback when an action is made.

So test for snackbars, not toasts, and as above, use /test/ rather than /androidTest

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

as below

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Apr 3, 2024
@david-allison david-allison marked this pull request as draft April 3, 2024 13:11
@neeldoshii neeldoshii changed the title Test : Check Toast is displayed when the deck is created Test : Check Snackbar is displayed when the deck is created Apr 4, 2024
@neeldoshii
Copy link
Contributor Author

Hi Maintainers, I am unsure of how can I check if the Snackbar is displayed or not in Roboelectric? There used to be shadowsnackbar but its now deprecated.

Can you share me what method do we have to test snackbar or any resource link?

@david-allison david-allison added the GSoC Pull requests authored by a Google Summer of Code participant [Candidate/Selected], for GSoC mentors label Apr 4, 2024
@neeldoshii neeldoshii closed this Apr 13, 2024
@neeldoshii neeldoshii reopened this Apr 13, 2024
@neeldoshii neeldoshii closed this Apr 13, 2024
@neeldoshii neeldoshii reopened this May 8, 2024
@david-allison
Copy link
Member

This should be in /test/, not in /androidTest

Closing this as stale to reduce our number of pending PRs. I was going to fix this up, but it needs a rewrite.

Feel free to recreate when this is done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GSoC Pull requests authored by a Google Summer of Code participant [Candidate/Selected], for GSoC mentors Needs Author Reply Waiting for a reply from the original author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants