Unit Testing definition
- Unit Testing is a Practice of testing certain functions and areas of code or individual units of source code :
- Unit Tests is a test that isolates and verifies individual units of source code.
- A Unit test is a way of testing a unit (the smallest piece of code) that can be logically isolated in a system.Unit Testing benefits
Unit Testing benefits
- Identify Failures to improve quality
- Easy to test Code produced
- Prevent future changes from breaking functionality
Unit Testing characteristics
- Code in each test is as small as possible while maintaining readability of the code.
- Each test is independent of other unit tests.
- They exercise the persistence layer of a solution.
- Each test makes assertions about only one logical concept.
Unit Testing practice
- Unit Testing is performed by Developers
- Code in each Unit test should be as small as possible while maintaining readability of the code.
- Low-level test focusing on small parts of a software system that can be executed fast and in isolation.
- The definition and boundaries of a ‘unit’ generally depends on the context and is to be agreed by all the Developers
- In most programming languages, that is a function, a subroutine, a method or property.
- A Unit test can be automated.
Good Unit Test
- A unit test is a separated and isolated test that validates a unit of functionality.
- A good unit test should have the following characteristics:
- A unit test does not depend on the environment
• Does not depend on the environment; e.g. it will run on your computer and it will run on your colleague’s computer
- A unit test does not depend on the environment
- Each Unit test should be independent of other unit tests.
- Does not depend on other unit tests
- Does not depend on external data
- Does not have side effects
- Asserts the results of code
- Tests a single unit of work (mostly a method)
- Covers all the paths of the code under test
- Tests and asserts edge cases and different ranges of data
- Runs fast
- Is well‐factored and as small as possible
Good Unit Test Attributes
- Asserts the results of code
- Is well‐factored and as small as possible
- Does not have side effects
- Tests and asserts edge cases and different ranges of data
- Runs fast
More informations for Scrum Testing
More informations for the Scrum PSD certification here.