Skip to content

New rule to organize unit test contents #13

Description

@daniellmb

@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?

Activity

  1. yanivefraim commented on May 6, 2015

    @yanivefraim
    Contributor

    Sounds cool. Are those patterns always relevant?

  2. daniellmb commented on May 7, 2015

    @daniellmb
    OwnerAuthor

    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.

  3. yanivefraim commented on May 7, 2015

    @yanivefraim
    Contributor

    OK, I'm with you on this (:

  4. daniellmb commented on May 7, 2015

    @daniellmb
    OwnerAuthor

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

  5. yanivefraim commented on May 8, 2015

    @yanivefraim
    Contributor

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

  6. daniellmb commented on May 8, 2015

    @daniellmb
    OwnerAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions