Static vs Dynamic Testing

Profile picture for user devraj

Static and dynamic testing are performed differently but complement each other by finding different types of defects. Also, both can have the same objectives, such as assessing the quality of the work products and identifying defects as early as possible.

Difference between Static and Dynamic Testing

Point of DifferenceStatic TestingDynamic Testing
DefinitionStatic testing is testing a component or system at the specification or implementation level without the execution of the code of the application under development. Dynamic testing is a software testing method that involves executing the component or system being tested.
Code DeploymentCode Deployment is not required in case of static testingDynamic testing is performed after code deployment.
Code ExecutionIn Static Testing, code is not compiled and executed.In Dynamic Testing, Code is compiled and executed.
CostStatic testing is less costly.Bug identified during dynamic testing is expensive to fix compared to static.
Defect Prevention or DetectionStatic testing prevents defects.Dynamic testing is done to find and fix defects.
Defect Identification in Work ProductsStatic testing finds defects in work products directly rather than identifying failures caused by defects when the software is run.A defect can reside in a work product for a very long time without causing a failure.  The path where the defect lies may be rarely exercised or hard to reach, so it will be challenging to construct and execute a dynamic test that encounters it. Static testing may be able to find the defect with much less effort.
ExampleVerification is an example of static testing. A dynamic Testing example is a validation.
Improve Consistency & Internal Quality of Work ProductsStatic testing can improve work product consistency and internal quality. Dynamic testing typically focuses on externally visible behaviors.
TechniquesStatic testing techniques are reviews, walkthroughs, inspections, etc.Dynamic testing consists of functional and non-functional testing and data/control flow analysis.
ToolsSome tools used for Static testing are: Checkstyle, Clang, Eclipse, Sonarqube, Soot, and Source meterSome of the tools used for dynamic testing are BoundsChecker, DroidBox, Diakon, Procmon, and ValGrind.
When PerformedStatic Testing is performed at an early stage of development.Dynamic testing is performed at a later stage.  

Static Testing Defects

Compared with dynamic testing, typical defects that are easier and cheaper to find and fix through static testing include the following:

  • Requirement defects: (e.g., inconsistencies, ambiguities, contradictions, omissions, inaccuracies, and redundancies)
  • Design defects: (e.g., inefficient algorithms or database structures, high coupling, low cohesion)
  • Coding defects: (e.g., variables with undefined values, variables that are declared but never used, unreachable code, duplicate code)
  • Deviations from standards: (e.g., lack of adherence to coding standards)
  • Incorrect interface specifications: (e.g., different units of measurement used by the calling system than by the called system)
  • Security vulnerabilities: (e.g., susceptibility to buffer overflows)
  • Gaps or inaccuracies in test basis traceability or coverage: (e.g., missing tests for an acceptance criterion)
  • Maintainability defects: Moreover, most maintainability defects can only be found by static testing (e.g., improper modularization, poor reusability of components, and code that is difficult to analyze and modify without introducing new defects).