Issues running suite file which has multiple parameters from command-line using maven

29 views
Skip to first unread message

Rivlin Pereira

unread,
May 16, 2013, 10:30:47 PM5/16/13
to webd...@googlegroups.com
Hi All,

I am trying to find out how to run a suite file which has multiple parameters from command line using maven. In IntelliJ to run this I just right click on the suite file and click run xml which runs it and sends the parameters in the suite file to my base class which all of my test cases extend. Is there a way to run the same parameterized suite file from command-line. I use this command to run a suite-file from command-line

     mvn test -Dtests=resources/test-suites/audioSuite.xml     

The suite-file looks like this -

    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
       <suite name="Image Upload Suite Firefox" verbose="1" >
          <test name="Image Upload Test" parallel="false">
          <parameter name="BROWSER" value="FF" />
          <parameter name="VERSION" value="20" />
          <parameter name="PLATFORM" value="WINDOWS" />
          <parameter name="NAME" value="Simple Image Upload Test" />
            <classes>
              <class name="audioTestsNodeFormPlus.xxxxxx"/>
            </classes>
          </test>
      </suite>

The base class looks like this -

    @BeforeClass
    @Parameters({"BROWSER","VERSION","PLATFORM","NAME"})
    public  void setup(String BROWSER, int VERSION, String PLATFORM, String NAME) throws   IOException {
        if (BROWSER.equals("FF")) {
            DesiredCapabilities capabillities = DesiredCapabilities.firefox();
            capabillities.setCapability("version", VERSION);
            capabillities.setCapability("platform", Platform.valueOf(PLATFORM));
            capabillities.setCapability("selenium-version", "2.32.0");
            capabillities.setCapability("name", NAME);

Also is there a way to run this from command line without passing parameters like -Dbrowser the reason I say that because I want to pass NAME from the suite file itself because this is displayed on the dashboard in sauce labs. I was looking at a similar post here http://selenium.10932.n7.nabble.com/How-to-execute-a-webdriver-test-script-using-Maven-and-Testng-in-cmd-prompt-td18393.html but does not solve my issue.
  
Thanks,
Rivlin 
Reply all
Reply to author
Forward
0 new messages