Skip to content
Eugenio Romano edited this page Mar 6, 2018 · 6 revisions

Test Naming convetion

In ADF we choose to write Behavior Driven Development (BDD) tests . BDD test are written in a non-technical language that everyone can understand. Following names are examples on how you should title a test:

  • Should_ExpectedBehavior_When_StateUnderTest
  • Should_ThrowException_When_ConditionIsSatisfied
  • Should_NotShowButton_IfUserIsGuest

Isolated unit tests and TestBed

  • You should write isolated unit tests for pipes and services.
  • You should use the Angular testing utilities include the TestBed class and several helper functions from @angular/core/testing for components

Bad test practices

  • Asynchronous tests without the use of done or the async function in it
  • Test tightly testing the code implementation
  • Test private function
  • Test depends on excessive setup
  • Test works only on developer's machine
  • Test works only in a certain order

Always remember the best way to have a meaningful green test is be sure that the test was failing before the creation of the feature or the bug fix

Resources