What is Assertion based testing?
An assertion is a boolean expression at a specific point in a program which will be true unless there is a bug in the program. A test assertion is defined as an expression, which encapsulates some testable logic specified about a target under test.
Benefits of Assertions:
The main advantage of having assertions is to identify defects in a program. The usefulness of assertions include:
- It is used to detect errors sooner after they occur.
- It is used to detect subtle errors which might go unnoticed.
- Make a statement about the effects of the code that is guaranteed to be true.
Limitations of Assertion:
Like any other piece of code, assertions may themselves contain errors. It can lead to the following problems:
- Reporting an error when it does not exist.
- Failing to report a bug that exists.
- Can Take time to execute if it contains errors and occupies memory as well.
- Can lead to other side effects.
How Assertions can block Testing?
If an assertion is failing due to one or the other reason, the consequence of the same can be severe. An Assertion could elevate to a stumbling block which might result in stopping testing for a whole day. Some conditions that we wish to test for might be conceptually simple, but it is very difficult to check in practice.Share This: