exercism / go-test-runner

GNU Affero General Public License v3.0
15 stars 17 forks source link

Code snippet output for subtests sometimes includes the whole test table #51

Closed junedev closed 3 years ago

junedev commented 3 years ago

The README of the test runner says that if you conform to a certain structure, the code that is shown on the website for a certain sub test only includes the parts that are relevant for that subtest. See https://github.com/exercism/go-test-runner#subtest-format-specification

However, there seem to be quite a lot of cases where the code seemingly conforms to the specification given in the README but the subtests show the whole test table on the website which is confusing for the students.

Here is one example, I will try to add more later on.

This is TestFirstTurn from the BlackJack exercise: https://github.com/exercism/go/blob/b8cccc8969db842b591f762e5426381a64880adc/exercises/concept/blackjack/blackjack_test.go#L175-L385

On the website the FirstTurn subtest code contains the full table of test cases (it is the same no matter whether the test failed or passed):

image

junedev commented 3 years ago

Another example is Gross Store "TestRemoveItem/Invalid_measurement_unit". image

My feeling this happens when the test table does not start immediately below the t.Run. In the cases I saw so far there was always a struct definition between t.Run and the table. This seems to trip up the test runner when it tries to extract the table.

That means we have to options: Fix the tests to not use this struct (e.g. use an anonymous nested struct instead) or fix the test runner so that it can handle the struct correctly.

junedev commented 3 years ago

Since I know my way around the test runner now, I will try to fix this as well.