Skip to content
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

Start on use-case oriented documentation #38

Merged
merged 4 commits into from
Nov 27, 2019
Merged

Start on use-case oriented documentation #38

merged 4 commits into from
Nov 27, 2019

Conversation

eliasson
Copy link
Contributor

@eliasson eliasson commented Oct 23, 2019

What about adding another type of documentation, one that is use-case oriented?

E.g. show how to assert when you have a list. Give tips and tricks both regarding the Intent API as well as practices on writing good tests (regardless of framework)?

I think such a document would serve new users as well as developers new to TDD / testing well. Intention is to showcase common situations and let the API specification (or matchers.md) cover the details.

Related to #27

@eliasson
Copy link
Contributor Author

eliasson commented Nov 3, 2019

@provegard any thoughts on this style of documenting?

> Avoid matching a collection on its length, as a failure will not give any details on the element(s) that were
> missing or extra. An alternative is to filter a larger list and match on a smaller inline list
> ```scala
> Example?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Difficult if you're after the length...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe just provide some tips? E.g.:

  • Testing length may be brittle if the producer is modified to create more items - testing that the list contains some and not others (two tests) is likely more stable.

By the way, we could modify toHaveLength to print the actual list, or at least parts of it (like we need to do with toEqual/toContain).

@provegard
Copy link
Collaborator

Very nice!

@eliasson
Copy link
Contributor Author

I'll merge this to master and we'll keep it up-to-date there on common scenarios.

@eliasson eliasson merged commit 69637de into master Nov 27, 2019
@eliasson eliasson deleted the how-to-assert branch November 27, 2019 22:23
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.

2 participants