-
-
Notifications
You must be signed in to change notification settings - Fork 5
Is the custom-set test set too long? #10
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
Comments
In most cases as soon as I get a function's first or second test to pass, all of the others pass without problem. This suggests to me that those tests aren't catching corner cases. Though they might be catching corner cases that I didn't happen to hit. |
Also, I'm wondering if the whole That's not to say it's not implementable, just that I have no idea how. It might be beyond the scope of the problem. |
/cc @exercism/track-maintainers |
This is something I've noticed with a lot of the common tests. Recently I went through the Clock tests and they also seemed to be a little bit overdone. I think that some of the tests are aimed at producing NASA-grade implementations instead of producing something that can be critiqued for style. On the other hand, the tests only need to be written once and I've never felt that a long list of tests burdened me when doing an exercise, so maybe it's better to have these bullet proof tests. |
Looks like the first two groups of tests you point to are in the common 0, 1, many pattern. I don't see that is being too redundant given that we are talking about a container. I'm not seeing the duplication in the subset tests and the intersection tests look "OK" in my skimming of them. If I were TDD-ing a set implementation I might not have all these tests myself (e.g. the intersection test that tests against empty as the first and second parameter) but I don't think they do much harm. |
@ryanplusplus, I'm less concerned about the work it takes maintainers to implement the exercise and more with the effect on students. There are two problems I see with big test suites, especially ones with redundant tests.
Assuming that a student is working their way through the tests, getting 1 to pass at a time, at which point do all of these tests pass? I'm guessing by test 5, when we check for duplicate elements. If so, what does a student learn from the remaining 3 tests? I think nearly all of these test collections could be consolidated into 3 tests each. Union, Intersect, Diff and Symmetric Diff could each have 3 tests:
|
A good indication I've found with test duplication is that I can't find a way to make test names unique. If I see a set of tests named:
Then I figure either I'm unimaginative (possible) or the tests cover the same ground. |
I suppose I don't have much to say about this specific issue since I haven't worked on the That should probably go in a separate discussion though. |
I would like to reduce duplication/unnecessary test cases in the tests. (Side note: With the clock tests I added more tests, because people were submitting solutions that had bugs that the test suite (in Go) wasn't catching. This was happening often enough that I thought more tests would be helpful. It's an interesting problem in Go; I don't know what it's like in other languages). |
I'm addressing two things in this commit. Bringing Tests in line with the Standard ==== Our suite of tests for Custom Set did not follow the [standard json file in x-common](https://github.com/exercism/x-common/blob/d6cd42db16fce5090bb486821a36d0fb1bfb7df2/custom-set.json) They tests have different function names, don't cover symmetric_difference and introduced some functions (`is_superset`) that aren't in the standard test file. I have not implemented the entire standard test suite as it covers sets of [mixed types](https://github.com/exercism/x-common/blob/d6cd42db16fce5090bb486821a36d0fb1bfb7df2/custom-set.json#L475) which I don't think is even possible in Rust. Vectors have to be homogeneous. Tuples can mix types, but can't change size. Mixed type sets may be possible, but implementing that seems way beyond the scope of this exercise. I think [this suite of tests is too long](exercism/discussions#10). But until I get a PR in to shorten the standard test suite, I figured I might as well follow it. Updating the API ==== I had a couple of problems with the current approach. First, the tests hide the actual API in a helper method. This was probably done to reduce duplication, but I find that it obscures the function under test. So I removed those. The tests also pushed towards a bunch of implementation that I found unnecessary, specifically the whole [Iter implementation](https://github.com/exercism/xrust/blob/04b665e989b578c4e46ff100b1b0a00d5df9bb0d/exercises/custom-set/example.rs#L118). There might be ways to get the current test suite passing without implementing Iter, but I got pretty stuck. My new implementation does not require this implementation, since equality comparisons are now handled by implementing PartialEq.
I'll put together a shorter test suite and put it up for a PR. See what people say. |
Discussed here: exercism/discussions#10 I'm trying to improve custom_set in two ways: 1. Reducing the test suite, to remove redundancy or uninteresting implementations. 2. Changing test order to improve flow Reducing the test suite ---- The previous test suite contained 74 tests, which is a lot. I haven't checked all the exercises, but it's the biggest test suite that I've come across. If all of those tests provided value (exposing corner cases, improving implementations, etc.) then that's fine. But I found there to be a lot of duplicate tests. With the subset/union/etc tests, a student's implementation is usually done by the 2nd or 3rd test, so the remaining tests didn't provide any additional value. So I have removed the tests that seemed redundant. The tests also expected methods like `size`, `delete` or `is_empty`. I have removed those because - They aren't vital to the behavior of a Set - They are usually implemented as an alias - They aren't used by the set operations (diff/subset/etc) Changing test order ---- The previous test suite started with `equal`. I found that this requires students to implement two things: - Creating a new element - Comparing two collections of elements I have chosen to start the tests with `contains`, since that only requires one set. And, helpfully, when the student implements `add` and `equal`, they can leverage their already-existing `contains` function.
@IanWhitney what about two non-empty non-intersecting sets? |
My claim that they should have 3 was wrong. I think each ended up with 4 tests. Did I cover the case you're asking about? https://github.com/IanWhitney/x-common/blob/reduce_custom_set_tests/custom-set.json#L204 |
{1,2} ∩ {3,4} = {} is what you mean, right? Sorry, early morning & my set math brain is not working. That should be covered with this test |
Multiple tests does not bother me al long as the test suite is able to group them into a "single" function. |
@IanWhitney yeah, that's what I was thinking of. |
I'm addressing two things in this commit. Bringing Tests in line with the Standard ==== Our suite of tests for Custom Set did not follow the [standard json file in x-common](https://github.com/exercism/x-common/blob/d6cd42db16fce5090bb486821a36d0fb1bfb7df2/custom-set.json) They tests have different function names, don't cover symmetric_difference and introduced some functions (`is_superset`) that aren't in the standard test file. I have not implemented the entire standard test suite as it covers sets of [mixed types](https://github.com/exercism/x-common/blob/d6cd42db16fce5090bb486821a36d0fb1bfb7df2/custom-set.json#L475) which I don't think is even possible in Rust. Vectors have to be homogeneous. Tuples can mix types, but can't change size. Mixed type sets may be possible, but implementing that seems way beyond the scope of this exercise. I think [this suite of tests is too long](exercism/discussions#10). But until I get a PR in to shorten the standard test suite, I figured I might as well follow it. Updating the API ==== I had a couple of problems with the current approach. First, the tests hide the actual API in a helper method. This was probably done to reduce duplication, but I find that it obscures the function under test. So I removed those. The tests also pushed towards a bunch of implementation that I found unnecessary, specifically the whole [Iter implementation](https://github.com/exercism/xrust/blob/04b665e989b578c4e46ff100b1b0a00d5df9bb0d/exercises/custom-set/example.rs#L118). There might be ways to get the current test suite passing without implementing Iter, but I got pretty stuck. My new implementation does not require this implementation, since equality comparisons are now handled by implementing PartialEq.
I'm addressing two things in this commit. Bringing Tests in line with the Standard ==== Our suite of tests for Custom Set did not follow the [standard json file in x-common](https://github.com/exercism/x-common/blob/d6cd42db16fce5090bb486821a36d0fb1bfb7df2/custom-set.json) They tests have different function names, don't cover symmetric_difference and introduced some functions (`is_superset`) that aren't in the standard test file. I have not implemented the entire standard test suite as it covers sets of [mixed types](https://github.com/exercism/x-common/blob/d6cd42db16fce5090bb486821a36d0fb1bfb7df2/custom-set.json#L475) which I don't think is even possible in Rust. Vectors have to be homogeneous. Tuples can mix types, but can't change size. Mixed type sets may be possible, but implementing that seems way beyond the scope of this exercise. I think [this suite of tests is too long](exercism/discussions#10). But until I get a PR in to shorten the standard test suite, I figured I might as well follow it. Updating the API ==== I had a couple of problems with the current approach. First, the tests hide the actual API in a helper method. This was probably done to reduce duplication, but I find that it obscures the function under test. So I removed those. The tests also pushed towards a bunch of implementation that I found unnecessary, specifically the whole [Iter implementation](https://github.com/exercism/xrust/blob/04b665e989b578c4e46ff100b1b0a00d5df9bb0d/exercises/custom-set/example.rs#L118). There might be ways to get the current test suite passing without implementing Iter, but I got pretty stuck. My new implementation does not require this implementation, since equality comparisons are now handled by via PartialEq.
Discussed here: exercism/discussions#10 I'm trying to improve custom_set in two ways: 1. Reducing the test suite, to remove redundancy or uninteresting implementations. 2. Changing test order to improve flow Reducing the test suite ---- The previous test suite contained 74 tests, which is a lot. I haven't checked all the exercises, but it's the biggest test suite that I've come across. If all of those tests provided value (exposing corner cases, improving implementations, etc.) then that's fine. But I found there to be a lot of duplicate tests. With the subset/union/etc tests, a student's implementation is usually done by the 2nd or 3rd test, so the remaining tests didn't provide any additional value. So I have removed the tests that seemed redundant. The tests also expected methods like `size`, `delete`. I have removed those because - They aren't vital to the behavior of a Set - They are usually implemented as an alias - They aren't used by the set operations (diff/subset/etc) The new test suite has 37 tests. A 50% reduction. Changing test order ---- The previous test suite started with `equal`. I found that this requires students to implement two things: - Creating a new element - Comparing two collections of elements I have chosen to start the tests with `empty`, followed by `contains`, since those can be passed quickly. When the student implement the later functions they can leverage their already-existing functions.
Discussed here: exercism/discussions#10 I'm trying to improve custom_set in two ways: 1. Reducing the test suite, to remove redundancy or uninteresting implementations. 2. Changing test order to improve flow Reducing the test suite ---- The previous test suite contained 74 tests, which is a lot. I haven't checked all the exercises, but it's the biggest test suite that I've come across. If all of those tests provided value (exposing corner cases, improving implementations, etc.) then that's fine. But I found there to be a lot of duplicate tests. With the subset/union/etc tests, a student's implementation is usually done by the 2nd or 3rd test, so the remaining tests didn't provide any additional value. So I have removed the tests that seemed redundant. The tests also expected methods like `size`, `delete`. I have removed those because - They aren't vital to the behavior of a Set - They are usually implemented as an alias - They aren't used by the set operations (diff/subset/etc) The new test suite has 37 tests. A 50% reduction. Changing test order ---- The previous test suite started with `equal`. I found that this requires students to implement two things: - Creating a new element - Comparing two collections of elements I have chosen to start the tests with `empty`, followed by `contains`, since those can be passed quickly. When the student implement the later functions they can leverage their already-existing functions.
I'm working on re-working the Rust implementation so that it follows the common test suite. I'm currently at 32 tests and I might be half-way through.
This seems long. It seems to be that a lot of these tests are repetitive. Or maybe they are trying to catch weird corner cases that simply aren't occurring to me.
Some examples
I'm not a Set Theory expert, so maybe these tests are catching useful bugs, but it does seem to me that there's a lot that could be trimmed.
Thoughts?
The text was updated successfully, but these errors were encountered: