Static Analysis in Testing
Static analysis in testing is the process of verifying that your code meets certain expectations without actually running it. This has a number of advantages. There are:
- With static testing, you can ensure consistent style and formatting.
- Check for common mistakes and possible bugs.
- Limit the complexity of code and
- verify type consistency
Testing vs Static Analysis
- All types of tests are it unit tests, functional tests, integration tests, etc run the code and then compare the outcome against known expected outputs to see if everything works OK.
- Testing checks if your code works or not whereas static checks if it is returned written well or not.
- On the other hand, static testing analyzes aspects such as readability, consistency, error handling, type checking, and alignment with best practices.
- The stack is not primarily concerned, with whether your code provides the expected output, but rather with how the code is written.
The reason I have introduced this section is that testing and static are complementary to each other.
Static Testing Tools
When it comes to testing React apps, we can employ five tools for static testing. There are:
You have been using typescript which ensures type consistency in your code. For ex: you cannot pass in a string ‘0’ if a function expects a numeric argument, typescript will flag that. I hope this article helps you.