🖌️
Product Process Documentation
  • Product Process Documentation
  • Definition of Done (DoD)
    • General checkpoints
      • Specific checkpoints by team
    • Important process: QA review & PO review
      • QA Review
      • PO Review
  • Work Items
    • Product Backlog Item (PBI)
    • Bug
      • Basic rules for creating a bug
      • How to report a Bug
    • Bugs Management
  • Code Standards
  • Different Test Levels
    • Unit Test
      • Frontend Unit Testing
        • What is a Unit Test?
        • How do I know if I am developing a good unit test?
        • AAA (Arrange, Act and Assert)
        • Overloaded test suits
        • Setup & Teardown
          • JEST Mocks
          • FakeTimers
        • Istanbul Annotations
        • C8 Annotations
        • JEST Runner (Debug unit tests with Jest)
    • Component Test
      • Frontend Component Testing
        • What is Component Testing?
        • Best practices
        • Bad practices
        • Setup
          • Sandbox
          • Mocks, Services and Providers
          • Test scenario
    • Integration Test
      • Frontend Integration Testing
        • What is a Integration Test?
        • AAA (Arrange, Act and Assert)
        • Best Practices
        • Bad practices
        • Setup & Teardown
        • How to create a scenario
          • Create the migrated app
          • Add to project
        • How to debug
        • Common problems
      • Testing Driven Development Guide and recommendations
    • Functional Test
    • Security Testing
      • Security Testing Tools
      • Frontend Security Testing
    • Performance testing
    • Best Practices
    • Test Documentation
  • Run test projects
    • General steps
    • Specific steps by team
  • DevOps
    • Pipelines
    • Builds
    • Specific information by team
    • Test plan
    • Service Hooks for Azure DevOps Notifications
      • Slack Notifications
      • Microsoft Teams Notifications
  • Dashboards
    • General
    • QA Dashboards
  • Release Process
    • General Steps
    • Specific steps by team
  • Migration Cells
    • Basics of testing process
  • Release process
  • References
Powered by GitBook
On this page
  • It targets only the most important parts of your code base
  • Provides maximum value with minimum maintenance costs

Was this helpful?

  1. Different Test Levels
  2. Unit Test
  3. Frontend Unit Testing

How do I know if I am developing a good unit test?

It targets only the most important parts of your code base

Just as not all tests are equal, not all parts of your code base deserve the same attention in terms of unit testing. The value that tests bring is not only in how those tests themselves are structured, but also in the code they verify. It is important that you direct your unit testing efforts to the most critical parts of the system and verify the others only briefly or indirectly.

Avoid unit tests for getters and setters methods, unless they have a higher degree of complexity than they usually are.

This would be an example of a get method that should not be unit tested. But it is always important to ensure that the property is being tested in another type of test such as an e2e.

get expandMode(): any {
    return PanelBarExpandMode.Multiple;
}

This is an example of a get method that should be unit tested.

get col(): number {
  return this.currentColumn &&
    this.currentColumn !== '' &&
    this.visibleColumns.length > 0
    ? this.visibleColumns.findIndex(
        (element) => element.id === this.currentColumn
      )
    : -1;
}

Avoid unit tests for methods that only perform serverEvents emits.

@serverEvent(
  'HeaderClickCustomAction',
  GridEXExtractors.HeaderClickCustomActionArgsExtractor
)
headerClickCustomAction(event: EventData): void {
  this.HeaderClickCustomAction.emit(event);
}

Some of the tests, such as integration tests, can go beyond the domain model and verify how the system as a whole works, including non-critical parts of the code base. And that's fine.

Provides maximum value with minimum maintenance costs

The hardest part of unit testing is getting the maximum value with the minimum maintenance cost. It is not enough to incorporate tests into a build system. It is also crucial to keep in the suite only those tests whose value far exceeds their maintenance costs. This last attribute can be divided into two:

  1. Recognize a valuable test (and, by extension, a low-value test).

  2. Write a valuable test.

PreviousWhat is a Unit Test?NextAAA (Arrange, Act and Assert)

Last updated 2 years ago

Was this helpful?