Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Steve Lombardi (Deactivated) - This seems OK but I wouldn't want developers to loose the flexibility to work how they work best. 

Comment:

  • Make it clear this is just a recommendation and doesn't always apply.
  • Add "when appropriate" or "for new code" in title or description?

Follow the Test-Driven Development Test Cycle.

...

Test behaviors, not methods or lines of code.

Comment:

  • May need to clarify that "exceptional" behaviors can be included and how
  • Mention that test names should also be from a behavior perspective

Write each test following the Behavior-Driven Development structure, i.e., Given/When/Then. In other words make sure each test:

...

Tests should have names that clearly indicate the behavior being  and state being tested. For instance, catalogReturnsMetacardIdWhenIngestSucceeds or exceptionThrownWhenInvalidUserNameProvided.

Joseph North I think test names should include the state under test as well as the expected behavior.

Question:

  • Do we care about long test names? How do we handle those? JavaDoc?
  • Refer to long name smell?
  • Failing test name should let you know what failed exactly without having to look at the test code.

Test Positive and Negative Scenarios

...

Warning

Some error scenarios are extremely difficult to test using end-to-end or component tests, which makes testing all exception scenarios at the unit test level even more critical.

Keep Related Tests Together?

Use Proper Assertions and Validations

...

Brendan Hofmann This should be reworded so it doesn't unintentionally exclude interacting permutations of otherwise identical behaviors.

Tracy Batie (Deactivated) Clarify that this is not across test layers, e.g., unit tests and component tests.

Mock Dependencies

When writing unit or component tests, mock all dependencies that may fail. This allows the tests to guarantee that the unit or component under test behaves as excepted when one of its dependencies fails.

Steve Lombardi (Deactivated) - Clarification: Are there are cases where it's acceptable to use a mock-less test? Can I setup a temp folder if it's easier? 

Comment:

  • Need to clarify that this doesn't apply to pojos, simple dependencies, Java basic classes or things like temporary files.

This is especially important in unit tests as these may be the only tests where some of those exception scenarios can be tested.

...

Tests Before Changes

Before changing, fixing a bug or refactoring existing code, always make sure that tests exist and pass first.

...