Replaying Keyword-Driven Tests from the Command Line

You must update the PATH variable to reference your JDK location before performing this task. For additional information, see JDK Installation for Microsoft Windows.

To replay keyword-driven tests from the command line, for example when replaying the tests from a CI server, use the KeywordTestSuite class.

  1. To execute a keyword-driven test from the command line, create a JUnit test suite with the @KeywordTests annotation. For example, if you want to execute the keyword-driven test My Keyword-Driven Test, create the JUnit test suite MyTestSuite as follows:
    @RunWith(KeywordTestSuite.class)
    @KeywordTests({ "My Keyword-Driven Test" })
    public class MyTestSuite {
    
    }
  2. Include the following in the CLASSPATH:
    • junit.jar.
    • The org.hamcrest.core JAR file.
    • silktest-jtf-nodeps.jar.
    • com.borland.silk.keyworddriven.engine.jar.
    • The JAR of folder that contains your keyword-driven tests.
    set CLASSPATH=<eclipse_install_directory>\plugins\org.junit_4.11.0.v201303080030\junit.jar;<eclipse_install_directory>\plugins\org.hamcrest.core_1.3.0.v201303031735.jar;%OPEN_AGENT_HOME%\JTF\silktest-jtf-nodeps.jar;%OPEN_AGENT_HOME%\KeywordDrivenTesting\com.borland.silk.keyworddriven.engine.jar;C:\myTests.jar
  3. Optional: Add a new .properties file to the project to set the values of any variables that are used for the execution of the keyword-driven test. For additional information, see Replaying a Keyword-Driven Test with Specific Variables.
  4. Run the JUnit test method by typing java org.junit.runner.JUnitCore <Name>, where the Name is the name of the JUnit test suite that you have created in the first step.
    Note: For troubleshooting information, reference the JUnit documentation at: http://junit.sourceforge.net/doc/faq/faq.htm#running_1.

Example

For example, to run the two keyword driven tests My Keyword Driven Test 1 and My Keyword Driven Test 2, create the following class:
package demo;

import org.junit.runner.RunWith;

import com.borland.silktest.jtf.keyworddriven.KeywordTestSuite;
import com.borland.silktest.jtf.keyworddriven.KeywordTests;

@RunWith(KeywordTestSuite.class)
@KeywordTests({ "My Keyword Driven Test 1", "My Keyword Driven Test 2" })
public class MyTestSuite {
	
}
To run the class from the command line, type the following:
java org.junit.runner.JUnitCore demo.KeywordTestSuite
To run the class from the command line, using global variables stored in the file c:\temp\globalvariables.properties, type the following:
java -Dsilk.keyworddriven.engine.globalVariablesFile=c:\temp\globalvariables.properties org.junit.runner.JUnitCore demo.KeywordTestSuite
For additional information, see Replaying a Keyword-Driven Test with Specific Variables.