Is it possible to put a condition to TestNG to run the test if that is member of two groups?

前端 未结 3 708
庸人自扰
庸人自扰 2020-12-16 06:38

I know you can define in your xml which groups that you want to run, but I want to know whether it is possible to say run these methods if they are both member of groups A &

3条回答
  •  清歌不尽
    2020-12-16 06:59

    You can do this with the TestNG beanshell support: http://testng.org/doc/documentation-main.html#beanshell (you are getting access to method, testngMethod, and groups)

    In your particular case, it would be something like this:

    
      
        
      
    
    

    You could also do a System.out.println() if you wanted to debug stuff.

    The catch here is that you need to define the "method-selectors" in the "test" block. For some reason, if you define the "method-selectors" in "suite" (which is syntactically correct), the filter is not applied.

    Debugging this with System.out.println() is going to help you understand whether the stuff even runs, or which methods it filters, so e.g.:

    
      
        
      
    
    

提交回复
热议问题