Automatic Logging using Aspects
In this lesson, we will see how to use AspectJ for logging all assertions done using TestNG Assert and SoftAssert.
We'll cover the following...
What is AspectJ? #
AspectJ is a seamless aspect-oriented extension to the Java programming language that enables clean modularization of crosscutting concerns, such as error checking and handling, synchronization, context-sensitive behavior, performance optimizations, monitoring and logging, debugging support, and multi-object protocols.
How can we use AspectJ for automatic logging? #
We can use AspectJ
for automatically logging whenever we are performing assertions using org.testng.Assert
(stops further execution of the test on failure) or org.testng.asserts.SoftAssert
(continues test execution, irrespective of whether the assertions are passing or failing. At the completion of the test execution, TestNG will show all the occurred failures, if any).
This strategy can be applied to various other ...