Automation framework with Reflection API
Maintaining automation frameworks have always been aiding in maintaining quality software releases. We are quite aware of some of the types of automation frameworks such as Modular Testing Framework and Data-driven Framework. Irrespective of design pattern of our automation framework, maintenance of code has always been a challenge.
In any automation framework, several calls to a data member are made through object of any class, be it any method or any other data member like a variable. For this approach to work flawlessly we must know the object we are using to access a class data members. There may be some scenarios in which we just have to implement a certain functionality without knowing the complete information like in which class the functionality is implemented or which method is implementing the functioanlity.
We have a concept known as Reflection in java so as to provide us with the benefits of object identification while we are writing our scripts. We need not to be aware of all the methods and classes in our framework. We can create instances of an unknown class and call methods on them.
We may enjoy few of the advantages in our automation scripts if we incorporate reflection in our automation framework.
Knowing a methods name and its parameter type, we can invoke a method through reflection.
Through reflection we can access the private variables and methods of a class with the help of its class object and invoke the method by using the object.
Leave a Reply