What is meant by the Test Assertion or Assertion testing?
Assertion refers to the declaration made, which may be either true or not true. Testing based on the conceptual logic of the assertion is commonly, known as Assertion testing. Usually, an assertion is set to be true, unless the bug is present in the software program.
Generally, it is an approach, which involves the usage of boolean expression or concept, to carry out the testing activity. In this technique, expression or equations are used, which encloses the certain specific testable logic, for the target component or module or functionality or feature, under the test. These expressions, formally plays the role of 'assertion' in the testing and helps in determining the fulfilment of the specified requirements.
Types of Assertions:
Below given are the few commonly used assertion types.
- assertEqual(String actual,String expected)
- assertEqual(String actual,String expected, String message)
- assertEquals(boolean actual,boolean expected)
- Assert.assertTrue(condition, message)
- Assert.assertFalse(condition, message)
- Makes the task of testing the product, effective.
- Identifies the errors, much earlier, before they actually become visible in the software product, i.e. it helps in detecting the defects, much faster.
- Explore the defects, which are so delicate and fine, that it is difficult to analyse and describe them, and most of the times, remain untouched.
- It is not guaranteed that the assertion itself would be error free.
- May fail to detect the error(s) that actually exists.
- May report the errors, which does not exist.
- An error in the assertion may increase the time of testing process.
- It makes use of additional or extra memory.
- It have may have non-desirable consequences or side-effects.
- Using assertion as an exception handling management, may results into deletion of error-checking mechanism, post software product release, as it might be possible that the assertion used for the testing purpose, may get removed before the final release of the software product in the market.