I would like to get your suggestion and help on implementing following problem. To give a view why I need this I am summarising what I am trying to achieve and why.
I have some test data what I would like to read from test ( I am not using any unit testing framework like testNG or jUnit purposefully ). The test data I read from excel and store in a Map like shown below ( I am using Java 8 ).
Map<String, String > testData = new HashMap<>();
testData.put("NAME" , "Some name");
testData.put("ADDRESS", "Some address");
Definitely I can access this test data from my test method and get the value like testData.get("NAME") where I need to specify and key in the key "NAME". That is error prone and time consuming while we are scripting test having large set of key value pair. To overcome that I would like to call the test data with the field name directly like below where I do not need to key in any value but I can choose from the available keys
testData.NAME
testData.ADDRESS
Can any body suggest how to achieve this or what are the different way to achieve this ? One thing to remember while trying to find solution, we do not know the size of Map<String,String> testData. It is dynamic and depends on the data present in excel sheet.
Aucun commentaire:
Enregistrer un commentaire