Static and Dynamic Testing
Testing is one of the most important phases in a software development life cycle. There are different testing techniques to effectively carry out the testing process. Each of those techniques can be classified as Static Testing and Dynamic Testing.
In this tutorial, we are going to learn about Static and dynamic testing and also check the difference between the two. So, let’s begin.
We are well aware of the testing in the V model. The 2V’s of it stands for Verification and Validation. Static testing is the verification while dynamic testing is part of the validation process. Let us learn about both the processes one by one.
Static testing is cost-effective testing where defects are identified without actual execution of the code. Static testing is performed to catch defects in the early stages of the project. Sometimes static testing catches bugs that are not found even during dynamic testing. Therefore, this method is as effective as dynamic testing.
Static Testing Techniques
There are 2 methods to approach static testing.
The review meeting or in other words manual examinations is finding potential defects in the system. These meetings are attended by all the team members to know about the progress of the project.
The discrepancies are sorted using SRS (System Requirements Specifications) documents.
The reviews are further divided into-
- Informal Reviews – The informal review has all the team members with the SRS document creator. He puts the document in front of everyone and everyone presents their views on the defects. This leads to the detection of defects in the early stages.
- Walkthroughs – Walkthrough reviews are performed by experts or skilled people. This is done to avoid unnoticed defects or bugs.
- Technical/peer review – Peer review is teamwork where colleagues check each others’ documents to detect and fix the bugs.
- Inspections – Inspection is reviewing the document by the higher authority.
2. Static Analysis
This is the other method or approach to perform static testing. In this, the codes are assessed written by the developers to maintain the quality. The static analysis is performed with assistance with some tools. For example, CheckStyle, SourceMeter and, Soot.
The Static analysis is further divided into – Data Flow, Control Flow, and Cyclomatic Complexity.
- Data Flow is associated with stream processing.
- Control Flow configures the implementation of instructions and or commands in a code.
- Cyclomatic Complexity is the measurement of the complexity of any code. This is directly proportional to the number of independent paths in the control flow graph of the program.
Use of Static Analysis
- Identifies dead code
- Finds endless loops
- Identifies incorrect syntax
- Detects unused variables
- Detects variables with undefined values
- Trouble in interfacing modules with their components
- Security vulnerabilities
But why static testing? Why is it important to test bugs in the early stages of SDLC?
Objectives of Static Testing
- To decrease the number of errors in the product
- In SDLC, the bugs are detected in the early stages through static testing.
- Saves time and money
- Bugs can be fixed easily
- To increase productivity
Dynamic Testing is executing codes with different variables for physical examination of the system. In this way, the dynamic behavior of the code is tested. The code is compiled and run in the run time environment to identify bugs or defects. This execution of the code is done keeping parameters like CPU usage, response time, and performance of the software in mind. Therefore, it is just the opposite of static testing.
Dynamic Testing Techniques
The dynamic testing of any component or system is approached in 2 different ways.
- White Box Testing
- Black Box Testing
White Box Testing – The white box testing is done keeping transparency between the tester and the system. This means the tester is aware of all the internal working and the codes. The code is tested line by line.
The white box testing is done by the developers as they are completely aware of the built and insides of the system.
The white box testing has one more aspect in it – Data flow/ control testing. Data flow testing as discussed once above is to verify the program’s test paths.
Once the white box testing is completed the system is sent to the testing team for Black Box Testing.
Black Box Testing – This is performed by the testers or the testing team who are unaware of the built and codes of the system. The goal is to only verify the functionality of the system against any input. They check whether the system is producing the expected output or not. Programming knowledge is not required for black-box testing. The tester should only be aware of product specifications and requirements.
The Black Box testing is further divided into-
- Functional Testing
- Non-functional Testing
Functional Testing – The focus of functional testing is on the verification of specifications of the system. The functionality of the components individually and together as a system is tested. Inputs are given to verify expected outputs. Functional testing includes- Unit Testing, Integration Testing, System Testing, and User Acceptance Testing.
Non-Functional Testing – The focus is on the aspects like performance, load, and response time of the system. The goal is to check if the system is meeting the expectations of the user or not. Non-functional Testing includes Load Testing, Performance Testing, Security Testing, Compatibility Testing, etc.
Why Dynamic Testing?
- It is to check if the application works fine after the installation process.
- The dynamic behavior of the code is checked and verified.
- It is to check how the system responds against different inputs or variables.
- The efficiency of the system is validated.
- Reveals the uncovered defects during the static testing.
- Helps in detecting security threats.
- The software is executed end to end. This ensures no bug is left to be covered.
Difference between Static and Dynamic Testing
Now that we have studied both types of testing techniques, let us differentiate them based on different parameters. This will make our understanding of these techniques clearer.
- When – Static testing is done in the early stages of software development while dynamic testing is performed in the later stages if of the software development.
- Code execution – In static testing, the code is not executed, this means it is done before the compilation. In dynamic testing the whole code is executed line by line, this means it is done after the compilation.
- Cost – Static testing is more cost-effective than dynamic testing.
- Defect coverage – The static testing is done without the code in the early stages so, it helps in the prevention of defects. While dynamic testing is a way to cure or fix the defects invisible during static testing.
- Part of V-Model – Static testing is part of the verification process while dynamic testing is part of the validation process in the V-model testing.
- Time – Static testing obviously consumes lesser time. This is because the code is executed line by line in dynamic testing.
This tutorial is shared by ArtOfTesting author – Kanika Rawat. She is a technology evangelist and loves to write on software development and software testing-related topics.