Skip to content

beer-song: Make canonical data more logical #661

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

Merged
merged 3 commits into from
Mar 10, 2017
Merged

Conversation

kytrinyx
Copy link
Member

@kytrinyx kytrinyx commented Mar 9, 2017

We were testing:

  • the first verse
  • (*) some random verse in the middle
  • each of the special case verses
  • (*) 4 consecutive verses
  • all verses

The two that are marked with an asterisk are not very logical choices in
terms of TDD.

The first asterisk is about the generation of individual verses.

The structure of the algorithm is that verses 99 through 3 all have the
same implementation. Then verses 2, 1, and 0 are all unique.

Instead of testing the first generic verse and some random generic
verse, it makes more sense to test the outer bounds: the first (99) and
the last (3).

The second asterisk is about generating consecutive verses.

When testing multiples, the natural progression isn't "4" then "all".

The best test data is the smallest number that is multiple, which is
two. Since that can be implemented with a simple concatenation of the
upper and lower bounds (verse of N + verse of M), it's useful to add
an extra case that pushes towards a loop.

Again, we want the smallest number that suggests a loop, which is three
consecutive verses, not four.

Then, finally, we have the full integration test, which is all the verses.

We were testing:
- the first verse
- (*) some random verse in the middle
- each of the special case verses
- (*) 4 consecutive verses
- all verses

The two that are marked with an asterisk are not very logical choices in
terms of TDD.

The first asterisk is about the generation of individual verses.

The structure of the algorithm is that verses 99 through 3 all have the
same implementation. Then verses 2, 1, and 0 are all unique.

Instead of testing the first generic verse and some random generic
verse, it makes more sense to test the outer bounds: the first (99) and
the last (3).

The second asterisk is about generating consecutive verses.

When testing multiples, the natural progression isn't "4" then "all".

The best test data is _the smallest number that is multiple_, which is
two. Since that can be implemented with a simple concatenation of the
upper and lower bounds (verse of N + verse of M), it's useful to add
an extra case that pushes towards a loop.

Again, we want the smallest number that suggests a loop, which is three
consecutive verses, not four.

Then, finally, we have the full integration test, which is all the verses.
@kotp
Copy link
Member

kotp commented Mar 9, 2017

PR #662 is set to merge into this branch...

@kotp kotp requested a review from rbasso March 9, 2017 22:02
rbasso
rbasso previously requested changes Mar 10, 2017
Copy link
Contributor

@rbasso rbasso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked it against the JSON schema and it is compliant.

In the future maybe we should reconsider the 3-level nesting, because it may not be needed here. Anyway, that reflects the original structure, so the file seems to have been correctly adapted to the new schema.

Just the exercise property needs to be changed.

}
]
}
"exercise": "beer-run",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that the exercise's name should be beer-song, which is the slug.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meh, not sure why I put that in there, I know it is beer-song. I can fix it now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rbasso good catch. Fixed.

@kotp kotp force-pushed the canonical-beer-song branch from 6ffaf1a to 9f3d48a Compare March 10, 2017 06:25
@kotp kotp dismissed rbasso’s stale review March 10, 2017 06:27

Changes made

@kotp kotp merged commit 7726c6a into master Mar 10, 2017
@rbasso rbasso deleted the canonical-beer-song branch March 10, 2017 06:34
@kytrinyx
Copy link
Member Author

What does is the "property" property supposed to contain?

We have the section "verse" which has the property "verse", and the section "lyrics" which has property "verses".

@rbasso
Copy link
Contributor

rbasso commented Mar 11, 2017

I'll check that now, @kytrinyx.

@rbasso
Copy link
Contributor

rbasso commented Mar 11, 2017

Ops! I guess let that one slip when reviewing. Sorry! Just opened #694 to fix that.

What does is the "property" property supposed to contain?

The property is just a camelCase string that uniquely identifies a test type. The name testType was not popular at the time, so we settled with property because it was considered general enough to capture any kind of tests.

I agree that the name is a bit strange at first, because most people are used to tests in the form f (input) == expected, for explicit values of input and expected. The natural naming for these simple tests would be function.

But it is easy to create tests that do not fit in that format: f (inputA) == f (inputB), or f (inputA) == g (inputB). It is artificial to use function in these, so we needed a more general name.

Also, there is the extreme case of property-based testing, which we don't have yet, AFAIK, but is the most general case.

Putting in simple terms, we are always testing some property of the solution, and hence this name. Makes sense?

@kytrinyx
Copy link
Member Author

Putting in simple terms, we are always testing some property of the solution, and hence this name. Makes sense?

That makes sense. Thanks for clarifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants