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
[REFACTOR] Split test classes into two: TestXXXNoRequest
& TestXXXRequest
#3407
Comments
Interesting idea. For "substantial changes but not testing the request part" you probably mean something like first testing that the immutability logic in #3249 works on an "internal" level before checking if it introduces any issues with the Bot AP? The downsides I see of splitting everything up into several classes are
An additional solution that came to my mind would be to monkeypatch |
can also be helpful in that case, yeah. Sometimes you want test a couple of (non-request) components together, but since they are mixed with longer taking request tests, it slows down development time. The current solution to this, adding a
It's a mostly one time thing and since each test doesn't depend on other tests it shouldn't cause issues.
The idea is when you open the file, it becomes instantly clear what should go where. I'll try to maximize this as much as possible.
I'd say it would decrease scrolling time. For example in a new API update, you'll have to currently scroll everywhere to modify existing tests (specially when you don't know exactly what to change). This is mostly happening cause it's not ordered. E.g.
maybe that could work as well, but it violates point 2. in the OP. It's daunting right now to check how the tests work, and this would introduce some hidden logic. |
Okay, this probably depends on the specific task. If I'm adding a new class, I imagine that sorting by request/no-request leads to me scrolling up & down quite a bit b/c I'm not necessarily adding the tests in that order. I may be proven wrong :)
Point 2 could be achieved at least partially by sorting the tests within the same class though, right? We could add a notable comment break between some, something like # <---------------------------------------------------------------------------->
# Tests Below this line make requests to the Bot API
# <----------------------------------------------------------------------------> Though I agree that skipping all the
I'm not sure if I correctly understand what you mean by the first part of the sentence. Another general question/comment: This would only make sense for the classes in the |
I mean new users, who are not too familiar with pytest have a hard time understanding what's going on, so some explicitness would help them more.
I'll also add a short comment next to each of these explaining how to use them.
yep. |
I wouldn't like that tbh. The comments would have to be repeated many times and may easily be forgotten when writing new tests. Plus, it's only really helpful once for each new person looking into the tests (which isn't that often). In total I'll vote +1 on adding an option to exclude requests-based tests (as I can see the benefit of that) and -0 on splitting tests into different classes for that (as I'm not entirely convinced of the benefit of that). I'd like to hear the opinion of the other team members before any PR is opened for this. |
Yeah that's a better idea, I like it |
I really like the approach of having a request and non request class to be fair. I can see the point about this being a lot of work to do for all tests at once, I neither see the point about more scrolling (I have to scroll a lot now anyway, and I usually do all the non request parts first before others for new Types in API updates), nor about "needing to remember", right now I need to remember to add flaky and nothing warns me if I forget it. Having this split up in two classes with one decorator will decrease repetition and make it way easier to catch if someone put a request test where it doesn't belong. +1 from me for implementing this. |
I like this idea. It's funny coming from me because I have never looked for a |
Currently each of our test files has about one TestClass, which tests everything about the class together. This is not optimal because:
Implementation
For example,
test_sticker.py
should now look like:Along with this change, I'll also try to simplify/shorten some tests, if possible.
The text was updated successfully, but these errors were encountered: