From: http://blog.csdn.net/tulituqi/article/details/17846463
Why should we introduce RF? In fact, at first we introduced RF to quickly carry out Automated Acceptance Tests and escort agility. This is an important tool, Jenkins, which also meets the requirements of friends in the group, this time I will introduce how to quickly and conveniently combine Jenkins with RF to perform automated testing on Windows (I have no machine in Linux, and the general steps are similar. Du Niang should have it ).
In fact, I personally think that the combination of RF and Jenkins is very simple. Let's summarize these points:
1. Download Jenkins
2. Add nodes
3. Install the robotframework plug-in
4. Configure job run test
If you are using Jenkins, you can skip the steps 1 and 2. Because the poor are relatively lazy, we also recommend lazy people. OK, let's get started.
1. Download Jenkins
: Http://mirrors.jenkins-ci.org/
We recommend that you download the war package. Go to the address above. There are war links and various types of release on the page. You can download them as needed, for more information, see du Niang.
If you do not have any special requirements for the Jenkins version, go to the first release of war to find the latest version.
Why is the war package the simplest? If you have tomcat, put the war package in the webapps directory and start your Tomcat directly.
Generally, the access path is http: // localhost: 8080/Jenkins.
If you do not have tomcat, it will be simpler. I will not teach you how to install Tomcat. Jetty is built into the Jenkins war package. We can directly use the command line Java-jar Jenkins. war can be started. For example:
Of course, I recommend this method, because jetty can be directly accessed by others. We can see that the address 0.0.0.0: 5th in the last 8080 rows directly changes the local machine to a server.
In tomcat, You need to modify the configuration IP address to 0.0.0.0. So it is much easier for a lazy person like me.
When you see a line of information: Jenkins is fully up and running, it indicates that the Jenkins service has been started.
We recommend that you access Jenkins in chrome at a faster speed. Open our Jenkins address: http: // 192.168.1.6: 8080 (the IP address is subject to your local IP address and can also be localhost. Compared with tomcat, you do not need to write Jenkins for the URL. The following page is displayed:
It's easy to build a basic Jenkins, just by using a command line.
Of course, there are many plug-ins that make it easier for us to use Jenkins, but this is not what I want to talk about in this article. If you need it, you can do it yourself, on the download war page, there is a plug-in link.
I recommend several commonly used plug-ins:
Ant, dashboard-view, disk-usage, subversion, etc. Jenkins is mature now, and there are many plug-ins. Find a suitable plug-in for you to install.
2. Add nodes
The machine on which we start the Jenkins service is called the master in Jenkins, while other machines connected to the master (physical machines and virtual machines can all be) are slave, also called nodes.
1. Click system management, and then click manage node. The following page is displayed:
2. Click create node.
(This is a static connection method, that is, I first set the node, and slave will connect the master node as the node. In addition, there is also a dynamic connection method. You do not need to set the node first and directly use slave. jar to connect it. I will not detail it here)
3. Enter the slave name and click OK.
Note the following points:
A. executors: indicates that several threads can be executed in parallel on the slave, or you can click the question mark to see the description. For RF, we recommend that you set it to 1.
B. Remote working directory: the path for creating the Jenkins working directory on slave. I usually set it to D: \ JK.
C. Label: one or more labels can be added to slave, and slave can be selected through the label
D. startup method: the method for starting slave. We recommend that you select the second launch slave agents via Java Web Start.
NOTE: If it is a server Load balancer instance used to execute RF automated test cases, you are strictly prohibited from selecting the Windows service method. Otherwise, the consequences will be borne by you.
We add two labels slavea and slaveall to this slave (the node name slave1 can also be used as the label). After setting the label, click Save.
As shown in the figure, there are multiple ways to start slave. Choose one to start slave. 2 is recommended. Then we will add another slave2, And the labels will use slaveb and slaveall. If there are machines, we can find two to connect them. If not, we can connect them to the Server Load balancer on our own, in this way, your machine becomes the master and slave, and it doesn't matter if you practice it.
That's what I did,
3. Install the robotframework plug-in
Next, we will install the plug-in. Most plug-ins are installed in a similar way, mainly introducing one of them.
1. Go back to the Jenkins homepage, go to system management, and click manage ins.
The following pages are available: updatable, optional plug-ins, installed, and advanced.
There is nothing to say about updatable and installed. All plug-ins and brief introductions are listed in the optional plug-ins. Click on the plug-in connection to go To the plug-in's home page, which provides a detailed introduction.
2. We mainly use the upload plug-in section on the Advanced page:
Here we need to upload the plug-in's HPI file, wait for him to prompt that the installation is complete, and then restart Jenkins to complete the installation.
At the very beginning, I can find the plug-in on the address page, which provides the RF plug-in download path http://mirrors.jenkins-ci.org/plugins/robot/ directly.
We recommend that you select 1.3.2 For the RF plug-in version. If you encounter an XML parsing error, you can join the QQ group, where there is a fixed version.
4. Configure job run test
Next, configure the job.
1. You are prompted on the homepage to create a task, or click the new link on the left to go to the new task page.
For RF jobs, the free style is enough. Multiple configurations are acceptable, but it is slightly inconvenient to configure multiple configurations. For example, you need to execute a set of cases on multiple slave with different configurations, you can use a job with multiple configurations.
2. first introduce the free style. Click OK to go to the job configuration page.
There are many configurable items. In order to quickly execute the case, we will first introduce the required items.
A. restrict where this project can be run: The preceding label is used here. Used to specify the label on which the job is executed. The specified slave label for multiple configuration items is not here.
B. Source Code Management: SVN is recommended for RF cases. This demonstration will not be processed. The next article will explain it briefly.
C. Build: we need to add the build step-Execute windows batch command. I will first write a simple command. For the complete command line parameters, you can enter pybot. bat -- help on the command line.
D. Post-build operation: add the post-build step-publishes robot framework test results. The first output can be blank by default if the previous pybot. if BAT specifies the output directory, it must be set here. Otherwise, output cannot be found. XML cannot parse the results.
3. Click build now to run the job.
You can click the progress bar to directly view the console output, or find the console output in the name of the point building in the menu to view the results.
4. Functions of RF plug-ins
The RF plug-in mainly uses the output. xml file after the RF operation to parse the results.
A. the Jenkins homepage displays the latest job build results. For details, see the last robot results column.
B. The running result trend chart is displayed on the job homepage.
Build meaning: I don't need to explain too much, just think it's just a job that runs once, generally, code packaging, compilation, and deployment are performed for the construction of development jobs. For the construction of RF jobs, an RF automated test case is run.
I was planning to get a master + slave figure. I was too lazy to draw it later. It was a master-centered figure, and many slave connections were made up.
1. slave machine configuration
You can use physical machines or virtual machines to deploy your server Load balancer instance. The machines used to execute RF automation cases need to install or configure the following:
1. Java environment, used to start slave connection Jenkins
2. the RF environment is the same as that on the top of the blog, that is, it is the same as that on your local machine. If a test library is installed locally, install the same test library on slave, because the actual execution is to call pybot on slave. if a test library is installed, the execution may fail.
3. Modify the RF encoding. Do you still remember the modification code I mentioned before to change cp437 to cp936? If this parameter is not modified, the console output page may not be able to see Chinese characters. It may be a bunch ????
Ii. Multiple configuration items
The job described above is a free-style project. In some cases, you may need to configure multiple projects. How is the difference between the job and the free-style project.
1. Different Configurations
The first is to specify the restrict where this project can be run of the tag, instead of configuration matrix.
There are several options to click Add axis. Generally, the first two are enough, and I have never used the first 3rd.
The first label expression is the expression of the input label, which is similar to the free-style restrict.
The second slaves is easier:
There are two options: labels and nodes.
Labels is the label we added when creating a node. If multiple slave instances have the same label, they are a group.
This method is suitable for executing multiple jobs on multiple slave instances. If a specific slave instance is specified to seize resources, then the resources are allocated as idle.
For example, a dozen machines in the management department are allocated in this way. Each machine in each test group has a separate label, and all machines have a unified label, in this way, you can allocate resources as needed during subsequent calls.
Individual nodes is actually the nodes in the node management. You can click it on your own.
2. Different execution results are displayed.
The difference between multiple configuration items and the free style is not only the difference between the slave tag and the display result.
I will select one label slavea for execution first.
A. On the Jenkins homepage, you can see that the robot results for multiple configuration items is empty.
B. There are no RF results on the job homepage.
Because I only configured one label, only default is displayed. Click default to view the running result of the default configuration.
If multiple tags are set, you can see the link of each configuration on the homepage. (I added a master, but there is no running case, so it is gray)
Click "slavea" to check the display of the job homepage of the free style:
The preceding figure shows the differences between multiple configurations and free styles.
3. Other useful job configurations 1. discard the old build
Check to discard the old build. There are several options,
Build retention days: How many days can each build be retained
Maximum number of remaining builds: Maximum number of remaining builds
In this way, you can reduce the storage of some master nodes and the history of job creation. Set it as needed.
2. Source Code Management
There are many source code management tools to choose from. If not, you can download the corresponding plug-ins. Below are the default existing
It is recommended that you use SVN to manage your rf case, submit updates locally, and then download the latest code from SVN to run each job.
The repositoryurl is your SVN path, and the local Module Directory is the local path after the download. The default directory is the current working directory. You can also define a directory by yourself. For example:
Of course, I used relative paths to write the case when executing commands:
Pybot. bat -- test *-v url: http: // URL-I regtest-D. \ result test \ testsuite.txt
After running the job, check the workspace again.
3. Create a trigger
It is also useful here. There are several triggering methods:
A. Execute only after other projects are built: This is suitable for continuous integration. The previous job is responsible for compiling and deploying the system, or executing automated unit tests, then, it will drive the current RF job to perform the automated acceptance test.
B. specify a time expression for running. For details, refer to help or Baidu.
MINUTE HOUR DOM MONTH DOW
Minute |
Minutes within the hour (0-59) |
Hour |
The hour of the day (0-23) |
Dom |
The day of the month (1-31) |
Month |
The month (1-12) |
Dow |
The day of the week (0-7) where 0 and 7 are Sunday. |
C. The difference is similar to the previous one. I remember that code changes are triggered and usually used for developed jobs.
For testing, the first two are enough.
4. Workspace
There is a link on the left side of the job page, workspace
The output result of each running operation is here. If the output directory is specified, it may not be here.
The RF plug-in also serves to copy each output file from the slave to the master, if there is not enough space on your master in the future, consider whether it is too large to copy the previous files each time. You can also discard the old build to clear it.
It is also a good choice to clean up the workspace of the job on slave.
5. permission management
Permission management is not involved in my current demo. It depends on what type of permission control you want to perform. If the company uses Windows domain for management, you can use active directory for configuration (which seems to be available by default. If not, download the plug-in for installation ).
On the system settings page of system management, there is an option to enable security (for the first setting, please click Security Settings on the system management page)
Select ad and configure your own domain controller address.
You can also use Jenkins's own user database to allow users to register and then authorize.
But what I want to say most is that you should pay attention to the following authorization policies::
If you want to allow only administrators to set this authorization policy, you must enable the security matrix or Project Matrix Authorization Policy.
Remember:Do not forget to add your users to the matrix before saving them.Otherwise, no one can go to system management.
After that, I had to clear all Jenkins directories and try again.
To add users/groups is to add user permissions to you. Remember to check all the selected permissions in The Matrix.
TIPS: the user permissions here, including the project user permissions, are case sensitive. Although both the case-sensitive user names can log on, if the matrix authorization is in lower case, in this case, a capitalized user does not have the permission to log in. This situation is extremely likely if the authorized user does not have the permission to perform operations after logon.
In fact, Jenkins is not only available for continuous integration, but we are also using automated regression testing, because the company is very concerned about daily building (run automated test cases every day) and the automated testing results of the regression day. In addition, because of the openness of the Jenkins platform, we can not only integrate RF, but also integrate other testing tools, even the gradually abandoned qtp has Jenkins plug-ins (I tried to use it, but it's not bad ).
I have introduced so much about the integration of RF and Jenkins, and I have hardly introduced the development part. This is not my focus. I believe there are many examples on the Internet, if you need to know about it, you can search for it by yourself.
We hope this part of content will help you quickly build your own Jenkins server and let your rf automated testing run on your own. We also hope that the integration of testers and developers on Jenkins will be better ~
Robot framework -- 11 RF combined with jenkins