Clear Code
  • Introduction
    • About This Book
    • Timeline
    • Software Killers
    • Billion Dollar Mistakes
    • Clear Code Overview
    • Clear Code Rules
  • Data Processing
    • Separate Data Collection And Processing
    • Create Data Models
    • Separate Use Cases
    • Data Should Be Immutable
  • Examples
    • Separate Use Cases With Data Model
  • Maintenance Cost
    • Consider the Maintenance Cost
    • The Software Exists In Time
    • Don't Feed the Monsters
  • OOP
    • Separate Data And Procedures
    • Do Not Use Inheritance
    • When To Avoid Inheritance?
    • What Is The Problem With Abstract Frameworks?
  • VARIOUS
    • The Real Single Responsibility Principle
    • The problem with Clean Code's name
    • How To Handle Warnings
    • Do Not Create Constant Collection Classes
  • Externals
    • Links
    • Quotes
    • Funny
  • Technology
    • Git Tutorials
  • Clean Code
    • Clean Code Introduction
      • Origin & Overview
      • Advanced
      • Typical Issues
    • Clean Code Outline
      • Why Clean Code?
      • Clean Code
      • Clean Code Approaches
      • Specification & Design
      • Duplication
      • Refinement & Refactoring
      • Conventions
      • Names
      • Types
      • Methods
      • Nulls and Validity Checks
      • Comments
      • Dead Code
      • Error Handling
      • Classes
      • Code Formatting
      • Unit Tests
      • Special Cases
      • Object Oriented Programming
      • General Code Smells
    • Clean Code Links
    • Clean Code TOC
    • Effective Java TOC
Powered by GitBook
On this page
  • Rules
  • Benefits
  • Code coverage
  • Good practices

Was this helpful?

  1. Clean Code
  2. Clean Code Outline

Unit Tests

It is not part of this document, find only some thoughts here.

Clean Code = Testable Code

Rules

  • Continuously write unit tests

  • Maintain unit test - keep them running

  • TDD - Test Driven Development

  • Tests must be clean too - they will change with the code

  • Tests must obey the test patterns

  • F.I.R.S.T. principles

Benefits

Enforces to write testable code Makes the code flexible - changes with regression tests

Code coverage

  • Try to reach higher levels (>90%)

  • Do not write tests only for the sake of the code coverage

Good practices

  • Use the default (package) visibility for the sake of the unit testing

Unit Testing briefly:

Last updated 5 years ago

Was this helpful?