Grade School: Update exercise and fix test structure
There was some work done to improve the Grade School exercise in the problem specification repo (https://github.com/exercism/problem-specifications/pull/1837).
Update
We want to update our version of grade school to match the latest problem spec version: https://github.com/exercism/problem-specifications/tree/main/exercises/grade-school
This involves ...
- [ ] replacing the current instructions.md content with the content of the description.md file from the problem spec repo (keep the current h1 header though)
- [ ] updating the tests.toml file to the latest version using configlet https://github.com/exercism/configlet/#configlet-sync (Installation hint: https://github.com/exercism/configlet/#use-in-your-track)
- [ ] either manually implementing the canonical test cases (see tests.toml for which should be included) or making use of the test case generator
- [ ] if necessary, update the exemplar solution so it passes the latest test cases
Fix Test Structure
The current test cases are done in a very ad-hoc way. While you are making sure that the test cases fit the canonical data, please also ensure all test cases are structured in an AAA (Arrange Act Assert) pattern like we are doing in the other exercises.
This is an example of the tests we have now:
func TestAddStudent(t *testing.T) {
exp := list([]Grade{{2, []string{"Aimee"}}})
s := New()
s.Add("Aimee", 2)
got := list(s.Enrollment())
if got != exp {
t.Errorf(`Add Aimee level 2, got
%sexpected:
%s`, got, exp)
}
}
The target structure is:
- A slice with all the test cases. It's ok to have different test cases for each test function.
- A
for rangeloop iterating over the test cases, acting on them and checking the result.
This is an example of a test suite of another exercise following the desired pattern: blackjack_test.go
Advantages of doing this:
- More maintainable tests
- Test code can be properly picked up by the test-runner
Hi there. Is this issue still up for grabs?
@PakkuDon Yes, this still needs to done.
@PakkuDon I assigned you. If you don't want to work on this anymore, let me know.