-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
NF: Move instrumented test functions #17419
NF: Move instrumented test functions #17419
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no issue with the extraction though it's not completely NF is it? (deck with unique name, one pressBack went away?)
structurally they are not test objects though, should be in testutils I think (sibling directory)
DeckWithUniqueName does not create a change in behavior. It is exactly the same behavior that the one that existed before this commit. It creates a deck based on the timestamp. The only difference being that now it generates the timestamp itself. This remove code duplication as many methods gave the same string as paramater. One back press indeed went away. Given that the method was used only in disabled test, I'd still argue that it's NF. I can remove the NF if you want. In any case, the second back press was the cause of the failure, so it had to be removed. Otherwise the method was not usable. |
I admit that it's not clear to me what is inside /anki, what is inside utils, testutils, test, an dialogs. |
85b69ed
to
2cb9100
Compare
Not sure on rules in all cases, but in this case test/ should have actual tests, and things just used by tests are in utils/ (or some utils dir, testutils/ seems used here already) because they are more like test utilities - at least that's where I think they should go I'm okay with those mostly-maybe-not-quite-NF changes, especially based on your comments |
Some functions in Reviewer Test were actually about DeckPicker or StudyOption I move them so that they become easier to find out and reuse. I also introduce some utility function to remove some code duplication. I expect to use those functions to repair tests in the deck picker test suite, and create deck option tests. The only actual difference is that createDeckWithCard now neds with a single `pressBack`. The second one was closing ankidroid, and thus causing the test to fail.
Let's consider the case where you want to test every second during 2 seconds. And the test takes .1 second. Then the first test starts at 0 second, halts at .1 second, and sleep until 1.1 second. The second run starts at 1.1 seconds, runs until 1.2 seconds, and the thread sleep until 2.2 seconds. Then there is no more run, as the 2 seconds limit is done. I expect in this case the developer wanted to run the test thrice, and actually test at or after 2 seconds. This change ensure it. It also remove the last useless sleep.
2cb9100
to
a842f55
Compare
I added a second commit @mikehardy. Because I believe the function as implemented was not exactly what a developer might expect while using it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the second commit does seem like an improvement, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers
This PR move some code so that it can easily be reused. Multiple PR are going to be based on them, and use the method the current PR introduce.