White box testing deals with the internal logic and structure of the source code. There are several White Box Testing Techniques. Some of them are as follows:
- Unit Testing
- Static Code Analysis
- Dynamic Analysis
- Coverage Analysis
- Statement Coverage
- Branch Coverage
- Loop Coverage
- Function Coverage
- Path Coverage, etc
- Mutation Testing, etc
Unit testing is testing a single unit of code as a whole. For example, in object-oriented approach a single unit could be a class. In this testing the single unit is isolated and test to determine whether it behaves as expected.
Static Code Analysis
Static code analysis is going through the code without executing the code, in order to find out defects, and improve code quality. There are several static code analysis tools that we can leverage and integrate into the application build process.
Dynamic analysis on the other hand involves executing the code and analyzing the program output.
In coverage analysis, we check if the source code is covered and executed during the test runs. For example, in statement coverage, we check what percentage of the code statements are executed by the tests. Ideally, we should design tests such that every statement of the application is executed at least once.
Mutation testing is injecting fault or seeding faults into the code and seeing if the test passes or fails.