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

New rule to organize unit test contents #13

Open
daniellmb opened this issue May 6, 2015 · 6 comments
Open

New rule to organize unit test contents #13

daniellmb opened this issue May 6, 2015 · 6 comments

Comments

@daniellmb
Copy link
Owner

@yanivefraim I've always used comments to help organize the contents of a particular unit test such as:

// arrange
// act
// assert

or

// given
// when
// then

What do you think about adding a new rule to require similar comments within the test patterns?

@yanivefraim
Copy link
Contributor

Sounds cool. Are those patterns always relevant?

@daniellmb
Copy link
Owner Author

No, not always, for example, on some unit tests there may be nothing to arrange. But I don't think it's detrimental/distracting to have the comments there even if there is nothing in that part of the test. I find it is a nice future extension point when you do need to add code to arrange the unit test context, it is clear where that code should go.

@yanivefraim
Copy link
Contributor

OK, I'm with you on this (:

@daniellmb
Copy link
Owner Author

Do you have a preference between "arrange, act, assert" and "given, when, then"?

@yanivefraim
Copy link
Contributor

I use "given, when, then", not sure what is better...

@daniellmb
Copy link
Owner Author

OK, thanks, I don't have a strong preference. I typically use AAA, but GWT may fit a little better with the Jasmine BDD style.

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

No branches or pull requests

2 participants