Search code examples
angularangular2-testing

Integrated testing vs Isolated testing in angular2


  1. What are the major differences between Integrated testing against Isolated testing ?
  2. When are these used?

Solution

  • Integrated Testing

    • Involves more efforts for
      1. Setting up the component to test (using TestBed)
      2. Check which are the child components and custom components
      3. Configure the properties and methods in those child (or) custom components, which throws error if failed
    • Even for a simple scenario involves more time as each and every property or their bindings has to be tested separately. This increases either of the below
      1. number of it blocks
      2. number of expect statements in a single it block
    • Attracts or tempts to write more test cases as reason is in the second bullet
    • No Pipes or Services are tested.

    Isolated Testing

    • No configuration is needed to test (including components)
    • Handles logic which has low complexity there by testing only the parent component and not worried about the child components.
    • For complex properties and bindings can be easily tested because the entire object can be passed into an expect statement which reduces the number of test cases unlike above.
    • Mainly used for unit testing the Pipes and Services as their functionality is completely independent