qmetry / qaf

Quality Automation Framework for web, mobileweb, mobile native and rest web-service using Selenium, webdrier, TestNG and Java Jersey
https://qmetry.github.io/qaf
MIT License
254 stars 138 forks source link

Custom annotation in feature file #363

Open AnbarasuMurugesan opened 3 years ago

AnbarasuMurugesan commented 3 years ago

Hi Team,

I am trying to integrate existing testng automation framework with QAF BDD. Existing framework looking for Group, Product, Tags annotation to push result to customized dashboard to maintain historical test results.

From QAF dashboard, I could able to see Group, Product values that I passed in feature file. Similarly I have to pass the same value to my existing dashboard from my custom report java class.

Sample feature file: Feature: Testing QAF integration with Testng Framework @Pre-requisities @dataFile:resources/testdata/login.csv @description:Testing @Product:Lantern Reporting Service @TestID:12345 @author:Anbarasu Murugesan @Group:TestingGroup Scenario: Login using valid credential Given load account data by name "${account}" Given launch application using "${clientType}" "${deviceId}" Given generate three legged oauth

QAF Dashboard: image

I tried to create Group.class to get value of annotation @Group:TestingGroup but it is not working as I expected. how to create Group.class to get value that I am passing in feature file package reporter; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Inherited @Retention (RetentionPolicy.RUNTIME) @Target ({ ElementType.TYPE }) public @interface Group { String group() default ""; }

Custom report java class -> passing method, , searchHierarchy, consumer. ifHasAnnotation(method, Group.class, true, a -> testResult.getTestCase().setGroup(a.group()));

cjayswal commented 3 years ago

It looks You are trying to access metadata.. If you have test method object you can cast to TestNGScenario that will give you metadata.

TestNGScenario scenario = (TestNGScenario) tr.getMethod();
Map metadata = scenario.getMetaData();