Software Testing

Q) What is Google Testing Pyramid? Which components does it include?

testing-pyramid

Unit Tests: Tests individual components of a software - a function, an API call etc.

Integration Tests: Tests a combination of components of a software - two microservices communication, backend-to-db communication etc.

End-to-End Tests: Tests the whole system, from begining until the end - an order takes place, front-end to backend, microservices communication, write to db etc.


Q) What are the metrics for unit test?

There are several coverage types of unit testing methodology:

  • Line Coverage: How many lines of code have been tested in percentage representation?
  • Branch Coverage: How many different branch paths (if, switch, loop) have been tested in percentage representation?

Let’s look at an example:

if (claim.isUrgent) {
    processUrgent(claim);
}
sendConfirmationEmail(claim);
  • Line Coverage: If the test goes into if block, then the line coverage is 100%.
  • Branch Coverage: If the test only checks the inside of the if block, branch coverage is 50%. If it checks the false case too, then the branch coverage is 100%.

Q) How about static code analysis? How does it differ from dynamic code analysis?

Static code analysis is simply the tests that are performed without running the code.

These checks usually include memory leak checks, catching bugs, finding potential security vulnerabilities.

Dynamic code analysis require code to be run - unit tests, integration tests, end to end tests are all variations of dynamic code analysis.

Static code analysis comes before dynamic code analysis.