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

GivenWhenThen for Test Methods #371

Open
lucasborin opened this issue Apr 9, 2021 · 2 comments
Open

GivenWhenThen for Test Methods #371

lucasborin opened this issue Apr 9, 2021 · 2 comments
Labels
new check New check

Comments

@lucasborin
Copy link
Member

Based on Use given-when-then, can we have a Check recommending the test method to follow the GivenWhenThen style?

The check could scan for given, when, and then keywords in comments and methods within a test method.

Further Reference: GivenWhenThen by Martin Fowler

@lucasborin lucasborin added the new check New check label Apr 9, 2021
@lucasborin
Copy link
Member Author

given can be empty. For instance, when you test an exception.

@pokrakam
Copy link
Contributor

Not in favour of this one. Firstly, although I broadly follow the pattern, it is often sensible to combine two of the stages or even all of them, e.g. cl_abap_unit_assert=>assert_initial( cut->meth( ) )..

Secondly, tests should also be simple and readable and put technicalities into helper classes. As such I feel it is unnecessary clutter to add comments to every two- or three line test.

Personally I subscribe to the idea that unit tests should document the code and like to make use of helper methods to keep tests as simple and readable as possible, see https://blogs.sap.com/2019/04/04/writing-simple-readable-unit-tests/
given-when-then comments would not add any value here.

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

No branches or pull requests

2 participants