Relative PathThe problem is not
Rft
Automated TestingAll Code involved in team development must solve the problem of relative paths. There are also a variety of solutions. For J2EE programs, middleware provides a context environment and also writes the root directory in environment variables or configuration files. Yesterday, I saw the getoption method provided by rft in the Forum. It is very convenient to use it to implement the relative path and migration of scripts.
Assume that the path of the rft automated test project is D:/ci_automation/src. Then, under SRC, We have/data,/scr ready PT,/lib,/common ...... Folder, then we write the code as follows:
String S = (string) getoption (ioptionname. datastore); system. Out. println (s)
In this example, the getoption method is a static method provided by rft and can be called directly. ioptionname is an interface provided by rft. The specific function is unknown. This interface has a static string datastore class member variable, stores the directory of the rft project. The above code is used to return the directory of the rft project. The running result is D:/ci_automation/src.
When we need to reference the/common folder, we can write as follows:
String file = S + "// common // test.xls "//JavaDirectory separator is required //
In this way, we even save the environment variables. Of course, this method is also conditional, that is, the rft software must be installed on the test machine.