jeudi 13 septembre 2018

How to get parameter value using reflection

I need method's parameter value to be used in my @BeforeMethod annotated method. Please suggest a way to do so. Here is my code:

Class A:

    @BeforeMethod(alwaysRun = true)
    public void beforeMethod(Method method)
        throws Exception {
    Parameter[] test = method.getParameters();

    //I need class B method's parameter value (Parameter Name = 
    //passwordParam) here. I managed to get the name of parameter

      }
    }

Class B (here class B extends class A):

     @Test(dataProvider = "UwAndBankerData")
     @RoleBasedTestCaseMappings({ @RoleBasedTestCaseMapping(testCaseNumber = 
     "1", userRole = a), @RoleBasedTestCaseMapping(testCaseNumber = "2", 
      userRole = b) })
     public void verifySiteAdminEditUWAdminOrBankerReport(String username, 
     String passwordParam, UserRole userRole)
        throws Exception { 
      //my code
      }





Aucun commentaire:

Enregistrer un commentaire