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
Replace 'defines correct option sets' tests with validation tests #4068
Comments
+1 on this idea. If I'm reading it correctly, this will require users to write more specific tests to validate their options? |
It ties it down to the implementation, that's true. On the other hand, one of the reasons we added option sets is to lift the burden of writing the same code again and again. We are sparing the contributor writing x extra lines of code and validation tests. With optional and dependent option sets coming up, that gain will increase. Will it not be much easier (for the contributors) if we implement the optionsets test logic in a central place that we can call from the separate command spec files? It will save a lot of lines of code and a lot of work. |
Agree. I think the logic to validate how option sets work should not be tested in the command test itself. The |
Correct @Jwaegebaert
Unfortunately, we can't do that @martinlingstuyl, because tests run in the context of a command, and only the command knows which options belongs to a set. Our tests should be decoupled from the how we implement validation, and should let us verify the correct behavior, even if the implementation changes. If we need to change tests each time we change the command's implementation, then in the long run it will lead to more effort. |
There are 170 commands that use option sets, 112 of them (in bold) don't use a specific option sets test:
|
Awesome work! If a command test suite doesn't have an option set test, it means that it properly tests for validation already, and we should be able to remove these commands from the list here. |
Would love to work on this one, can you assign me please? |
Sure thing @nicodecleyre, good luck! |
In some commands we have the 'defines correct option sets' test that verifies if the command defines the correct option sets. Thinking of it, it's not the right way about checking validation. Each time we change something about the command's option sets, we need to adjust the tests as well, which means we need to apply each change in two places. It also tightly couples the implementation with the test. A better way about it would be to add tests that verify that command fails validation when incorrect options are passed, irrespective how it's implemented in the command itself.
Before we start implementation, we should list all commands that require changing.
The text was updated successfully, but these errors were encountered: