How to pass java code a parameter from maven for testing

后端 未结 6 1428
故里飘歌
故里飘歌 2020-11-30 03:17

I need to pass on following values …

exeEvironment (Test environment) , testGroup (Group in testNG)

from Command-Line ->

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 03:57

    You need not define anything for groups in testng xml or the pom, the support comes inbuilt. You can simply specify the groups on the cmd line http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#groups

    Hope it helps..

    Edit 2:

    Ok..so here's another option...Implement IMethodInterceptor

    Define your custom property. Use -Dcustomproperty=groupthatneedstoberun in your command line call.

    In the intercept call, scan through all methods ..something to the effect..

    System.getProperty("customproperty");
    for(IMethodInstance ins : methods) {
        if(ins.getMethod().getGroups()) contains group)
            Add to returnedVal;
        }
    return returnedVal;
    

    Add this to the listeners list in your xml.

提交回复
热议问题