score:1

Accepted answer

have you considered using a build tool like maven for your project? it designed to do exactly what your asking. all of your project configuration is contained within one file. your tests are more portable and it allows for easy execution of your test scripts anywhere.

here is a basic example pom.xml configuration file:

<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/pom/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"
         xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelversion>4.0.0</modelversion>
    <groupid>groupname</groupid>
    <artifactid>artificatid</artifactid>
    <version>0.0.2</version>
    <name>selenium tests</name>
    <properties>
      <!-- compiler settings -->
      <maven.compiler.sources>1.8</maven.compiler.sources>
      <maven.compiler.target>1.8</maven.compiler.target>
      <!-- build info -->
      <build.timestamp>${maven.build.timestamp}</build.timestamp>
      <project.build.sourceencoding>utf-8</project.build.sourceencoding>
      <testng.congig>${testsuite}</testng.congig>
      <aspectj.version>1.8.9</aspectj.version>
      <allure.version>1.4.14</allure.version>
    </properties>
    <dependencies>
      <dependency>
          <groupid>org.testng</groupid>
          <artifactid>testng</artifactid>
          <version>6.8.8</version>
          <scope>test</scope>
      </dependency>
      <dependency>
          <groupid>ru.yandex.qatools.allure</groupid>
          <artifactid>allure-testng-adaptor</artifactid>
          <version>${allure.version}</version>
      </dependency>
      <dependency>
          <groupid>org.seleniumhq.selenium</groupid>
          <artifactid>selenium-java</artifactid>
          <version>3.0.1</version>
      </dependency>
    </dependencies>
    <build>
      <plugins>
          <plugin>
              <groupid>org.apache.maven.plugins</groupid>
              <artifactid>maven-compiler-plugin</artifactid>
              <version>3.1</version>
              <configuration>
                  <source>${maven.compiler.sources}</source>
                  <target>${maven.compiler.target}</target>
                  <encoding>${project.build.sourceencoding}</encoding>
                  <showwarnings>true</showwarnings>
                  <showdeprecation>true</showdeprecation>
              </configuration>
          </plugin>
          <plugin>
              <groupid>org.apache.maven.plugins</groupid>
              <artifactid>maven-surefire-plugin</artifactid>
              <version>2.18.1</version>
              <configuration>
                  <argline>
                      -javaagent:${settings.localrepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
                  </argline>
                  <suitexmlfiles>
                      <suitexmlfile>target\test-classes\${testng.congig}</suitexmlfile>
                  </suitexmlfiles>
              </configuration>
              <dependencies>
                  <dependency>
                      <groupid>org.aspectj</groupid>
                      <artifactid>aspectjweaver</artifactid>
                      <version>${aspectj.version}</version>
                  </dependency>
              </dependencies>
          </plugin>
      </plugins>
      <resources>
          <resource>
              <directory>src/test/resources</directory>
              <includes>
                  <include>*.xml</include>
              </includes>
          </resource>
      </resources>
    </build>

    <reporting>
        <excludedefaults>true</excludedefaults>
        <plugins>
            <plugin>
                <groupid>ru.yandex.qatools.allure</groupid>
                <artifactid>allure-maven-plugin</artifactid>
                <version>2.2</version>
            </plugin>
        </plugins>
    </reporting>
</project>

executing your script from the command line is as easy as:

mvn -fn clean install -dtestsuite=your_test_suite.xml

maven is highly configurable and allows you to setup your projects as you like.

heres a more detailed explanation: http://toolsqa.com/java/maven/configure-selenium-continuous-integration-maven/


Related Query

More Query from same tag