![]() |
T-Plan Robot Enterprise Doc Home |
1 August 2016 |
http://jenkins-ci.orgThe native release is the easiest way to go. In this guide we will install native Windows release of Jenkins 1.563 on a Windows 8.1 system.
TIP:
For details on how to integrate Jenkins running as a service
with T-Plan Robot see the Advanced Tips
chapter. |
To start Jenkins manually open a command prompt, change to the
Jenkins install directory (typically C:\Program
Files\Jenkin
s or C:\Program Files (x86)\Jenkin
s)
and execute:
To open the Jenkins web interface open http://localhost:8080 in a web browser.jre\bin\java -jar jenkins.war
Download the demo Java application (~20 kB)
"C:\Program
Files\Ant"
"C:\Program
Files\Ant\bin"
folder to the system path and configure
the JAVA_HOME
variable:<previous_path>;
C:\Program Files\Ant\apache-ant-1.9.4\bin
JAVA_HOME
and the value is the JDK
install path (for example C:\Program
Files\Java\jdk1.7.0_51
)TIP: If
you have a NetBeans installation it contains an Ant instance
you may reuse. Some NetBeans releases also contain a JDK.
You must only configure the variables or add the locations
through the Jenkins' Configure page. |
The next step is to integrate the project of your application
with CI (Jenkins). For simplicity we presume that the application
is not under a version control (CVS, SVN etc).
clean jar
The project is now set. To initialize the local project workspace
we have to build it:
build.xml
file. Download the sample
project and unzip it into the location mentioned in the log
(typically <user_home>\.jenkins\
jobs\DemoApp\workspace
).
Then go back to the project page and click "Build Now"
again. This time it should succeed.Before we design the automated testing we have to choose the test
environment configuration. T-Plan Robot supports a number of
architectures that involve one or more machines and/or mobile
devices. For an overview see the Supported
Configurations tutorial topic.
For the purpose of this guide we will choose the simplest
single-machine scenario. We will test the application on the
Jenkins machine using the Local Desktop
connection. The T-Plan Robot project with the test code can be
downloaded here:
Download the T-Plan Robot test project (4 kb)
The test project is cross platform and it will work on any Java
supported platform (MS Windows, Mac OS X, Unix, Linux, Solaris
OS). Unzip the project archive and open the folder it contains
using File->Open Project under the T-Plan Robot
GUI. The project contains one test script (tpr/Jenkins.tpr
)
and one template image of the icon used by the Close
button of the test application.
The script tests a very simple scenario:
If you set the variable APP_HOME
variable (line #3)
to the location where you unzipped the demo application you can
execute the script right away. Requirements:
"Exec kill"
command. The
script will also execute on older releases but it will not kill
the application if it for some reason fails to close. The
Jenkins build will then hang because it will wait for all
processes to complete.In order to produce a reasonable test report the script creates a
few result objects. It creates an XML report at line 17. It gives
the script a name and a number (line 23) and it creates two step
results (lines 40 and 54) and a screen shot (line 41). To view the
resulting report see the Test Results tree node of
the Robot project or open the online copy here.
In the next step we will integrate the test script into
Continuous Integration.
Integration with CI is enabled thanks to the T-Plan Robot command line interface (CLI). The most important options:
To create the start command suitable for CI integration use the CLI Wizard tool. To start it select Tools->CLI Wizard in Robot:
CLI Option
Description
-r/--run <path>
Execute the test script or schedule specified by <path>.
-c/--connect
-p/--password
Connect to a test environment. The password is optional and should be used only where required, such as for example for VNC Server connections. Connection can be also established directly from the script through the Connect command (TPR scripts) or connect() method call (Java scripts).
-n/--nodisplay
Execute in the CLI mode without displaying the GUI. It is recommended for production environments because this mode consumes less system resources (CPU, RAM). This option is required for remotely started executions (telnet, rsh/ssh).
-v/--variable <name=value>
Override a variable value. This option may be specified multiple times to override multiple variables. It is typically used to parametrize the script execution or to change the behavior through setting of the standard (predefined) variables. For example, to make the script save the report to C:\reports
specify:
-v "_REPORT_DIR=
C:\reports"
The WORKSPACE system variable will be set by Jenkins to the application workspace path. The BUILD_NUMBER one will contain the unique build number. For example, if the workspace is%WORKSPACE%\reports\%BUILD_NUMBER%
C:\Users\JohnDoe\.jenkins\jobs\DemoApp\workspace
and the build number is 3 the report will be stored to
This will make the report available at the following URL. You may also navigate to the report from Jenkins through the Workspace link in the project's (job's) menu.C:\Users\JohnDoe\.jenkins\jobs\DemoApp\workspace\reports\3
http://localhost:8080/job/DemoApp/ws/reports/3/results.xmlThis allows you to send the test result URL by email after every build. This can be achieved through the Email-ext (Email Extension) Jenkins plugin. To enable valid URLs you will also have to go to Manage Jenkins -> Configure and set the Jenkins Location to a valid host name. For other report options see the Advanced Tips chapter.
To integrate the automation to the build process simply add a new
build step:
TIP: To
debug the test script under Jenkins remove the -r and -n
options from the command temporarily. This will make Jenkins
start the Robot GUI without starting the automation. You may
then execute the script manually in Robot and debug it.
Jenkins will not complete the build until you close Robot. |
Jenkins running as a service is typically restricted in two
areas:
-o "config.licenseKeys=<license_key_path>"
--cfg
and --licensekey
options.cliMode
field of
the ApplicationSupport
class as follows before the
class is instantiated for the first time. When it's omitted the ApplicationSupport
constructor will throw a java.lang.ExceptionInInitializerError
.
This will be fixed in release 4.0.import com.tplan.robot.*;
import java.lang.reflect.Field;
...
try {
Field field = ApplicationSupport.class.getDeclaredField("cliMode");
try {
field.setAccessible(true);
field.set(null, true);
} finally {
field.setAccessible(false);
}
} catch (Exception e) {
e.printStackTrace();
}
ApplicationSupport a = new ApplicationSupport();
...
The steps:
%BUILD_NUMBER%
.
It can only link to static locations in the project workspace.
To work around this we have to make the Robot script create an
HTML copy of the report in a stable directory. To achieve it add
the following command to the Jenkins.tpr
script:Report "..\latest\results.html" desc="Testing of the Jenkins demo application, build {_ENV_BUILD_TAG} ({_ENV_BUILD_ID}) located at {_ENV_WORKSPACE}"
HTML directory to archive: reports\latest
Index page[s]: results.html
Report title: Latest T-Plan Robot Report
With the steps above allow you will be able to integrate T-Plan
Robot automated testing with the Continuous Integration tool of
your choice. The principles of the CLI integration can be applied
to integration with virtually any other framework.
The document does not cover other test environment configurations
involving multiple test machines. These will be discussed later.
Should you have any question please contact the T-Plan Support
team.