We are developing a web application, in which we run robot framework regression tests against. I'd like to be able to run specific robot framework tests based on tags from git so I wouldn't have to run full regression every time.
Currently I use Jenkins to execute windows batch commands. My first job pulls down everything from the repository.
cd /d C:\home\(Repository here)
git pull --summary
My second job runs the tests I specify, which is full regression currently.
robot -P C:\home\(Repository root here) C:\home\(Path to test cases)
Is there a way to run specific tests based on certain tags in git? For example running the "Login" tests because someone pushed a commit that had the [Login] tag in their commit message.
Here's an example of a test suite.
FileName = C:\\home(Repo)\\Regression\\Common\\Login\\LoginTestSuite.txt
*** Settings ***
Documentation Login Test Suite
Suite Setup Suite Setup
Library SeleniumLibrary
Force Tags LoginTests
*** Test Cases ***
User A Login Test
[Documentation] This is documentation
[Tags] Requirement A
(Test Steps Here)
Additional Information
Robot Framework Version: 3.0.4
Application Front End: AngularJS
Application Back End: C#
By the discussion in the comments, your goal is to run the Robot Framework tests having specific tags; these tags are coming from the git tags in the latest merge (let's call them "gtags" , to distinguish the two).
One specifies the cases to be ran based on their tags through the --include
command-line option ; so if the gtags include "LoginTests", you'd run only them like this:
robot -P C:\home\(Repository root here) --include logintests C:\home\(Path to test cases)
If the gtags are more than one, say they are (LoginTests, LogoutTests)
, you could append more --include
options:
--include logintests --include logouttests
Another option is to combine them in a single include
argument - RF allows that by using the "AND", "OR" & "NOT" boolean operators inside the value:
--include logintestsORlogouttests
With "AND" only the cases having both tags will be picked, "OR" - the cases having either of the tags (sounds like your case), "NOT" negates the follow-up logic. These three control strings are case-sensitive .
Naturally, for this scheme to work the gtags must be the same as the ones you've put in the test cases. If not, you'll have to add some logic to map the gtags to the ones in the cases ("Login" -> "logintests").
The tags in RF are normalized - converted to lowercase and all spaces are removed; for RF "LoginTest" == "Login Test" == "login test" == "logintest"
(though the usage of whitespace is discouraged - it's too easy to put two in the source, thus assigning two separate tags to the case) . So whatever casing comes from the gtags, they'll be matched if after normalization the strings are the same.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.