Contents
What results in an infinite loop?
An infinite loop occurs when a condition always evaluates to true. Usually, this is an error. If the value of i is negative, this goes (theoretically) into an infinite loop (in reality, it does stop, but due to a unusual technical reason called overflow. However, pretend it does go on forever).
How do you know if its an infinite loop?
In each iteration you calculate a number (the sum of the squares of the digits or the previous number). You can put all those numbers in a Set. If in some iteration you calculate a number that is already in that Set, you know that you are stuck in an infinite loop.
Is it possible to write a program that can check for infinite loops?
Yes, you are most definitely able to detect and break out of an infinite loop, by attaching a symbollic a debugger to the process and examining execution of the code.
What’s the difference between unit testing and integration testing?
A unit test tests small pieces of code or individual functions so the issues/errors found in these test cases are independent and do not impact the other test cases. Another important advantage is that the unit test cases simplify and make testing of code easier.
How to find the right balance between unit, integration and end to end tests?
Integration tests typically focus on a small number of modules and test their interactions. The key is to find the right balance between unit, integration and end-to-end tests. According to Google’s Testing Blog: To find the right balance between all three test types, the best visual aid to use is the testing pyramid.
Functional tests are related to integration tests, however, they signify to the tests that check the entire application’s functionality with all the code running together, nearly a super integration test.
How are unit tests different from end to end tests?
Unlike end-to-end tests that rely on external components, unit tests are not flaky. If I can build a project on my machine, I should be able to run its unit tests. In contrast, end-to-end tests would fail if some external component, like a database or a messaging queue, is not available or cannot be reached.