Mark test version to execute backward-compatible test cases

Hi Bruno,

Think of the tags more like an identifying string rather than a key:value pair.

Referring to the documentation for Tag patterns and Simple patterns I came up with the following example for you:

Example robot file:

marques-bruno_1.robot

*** Test Cases ***

#
# Version 1
#
TC1 - v1.0
	[tags]  Version_1.0
	Log    TC1 - v1.0

TC1 - v1.1
	[tags]  Version_1.1
	Log    TC1 - v1.1

TC1 - v1.2
	[tags]  Version_1.2
	Log    TC1 - v1.2

TC1 - v1.3
	[tags]  Version_1.3
	Log    TC1 - v1.3

TC1 - v1.5
	[tags]  Version_1.5
	Log    TC1 - v1.5

TC1 - v1.9
	[tags]  Version_1.9
	Log    TC1 - v1.9

#
# Version 2
#
TC1 - v2.0
	[tags]  Version_2.0
	Log    TC1 - v2.0

TC1 - v2.1
	[tags]  Version_2.1
	Log    TC1 - v2.1

TC1 - v2.2
	[tags]  Version_2.2
	Log    TC1 - v2.2

TC1 - v2.3
	[tags]  Version_2.3
	Log    TC1 - v2.3

TC1 - v2.7
	[tags]  Version_2.7
	Log    TC1 - v2.7

TC1 - v2.9
	[tags]  Version_2.9
	Log    TC1 - v2.9

#
# Version 3
# 
TC2 - v3.0
	[tags]  Version_3.0
	Log    TC1 - v3.0

TC1 - v3.1
	[tags]  Version_3.1
	Log    TC1 - v3.1

TC1 - v3.2
	[tags]  Version_3.2
	Log    TC1 - v3.2

TC1 - v3.3
	[tags]  Version_3.3
	Log    TC1 - v3.3

Examples of calling this file:

Run everything:

% robot marques-bruno_1.robot                     
==============================================================================
Marques-Bruno 1                                                               
==============================================================================
TC1 - v1.0                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.1                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.2                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.3                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.5                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.9                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v2.0                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v2.1                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v2.2                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v2.3                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v2.7                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v2.9                                                            | PASS |
------------------------------------------------------------------------------
TC2 - v3.0                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v3.1                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v3.2                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v3.3                                                            | PASS |
------------------------------------------------------------------------------
Marques-Bruno 1                                                       | PASS |
16 tests, 16 passed, 0 failed
==============================================================================

Run only version 1.x test cases

% robot --include 'Version_1*' marques-bruno_1.robot                             
==============================================================================
Marques-Bruno 1                                                               
==============================================================================
TC1 - v1.0                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.1                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.2                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.3                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.5                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.9                                                            | PASS |
------------------------------------------------------------------------------
Marques-Bruno 1                                                       | PASS |
6 tests, 6 passed, 0 failed
==============================================================================

Run all version 1 test cases and all version 2 up to version 2.2

% robot --include 'Version_1.*' --include 'Version_2.[1-2]' marques-bruno_1.robot
==============================================================================
Marques-Bruno 1                                                               
==============================================================================
TC1 - v1.0                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.1                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.2                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.3                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.5                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v1.9                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v2.1                                                            | PASS |
------------------------------------------------------------------------------
TC1 - v2.2                                                            | PASS |
------------------------------------------------------------------------------
Marques-Bruno 1                                                       | PASS |
8 tests, 8 passed, 0 failed
==============================================================================

Naturally if you want to test version 2.7:

robot --include 'Version_1.*' --include 'Version_2.[1-7]' marques-bruno_1.robot

or version 3.3:

robot --include 'Version_1.*' --include 'Version_2.*' --include 'Version_3.[1-3]' marques-bruno_1.robot

Or for version 3.3 you could also do:

robot --include 'Version_[1-2].*' --include 'Version_3.[1-3]' marques-bruno_1.robot

this might be useful if you wanted to test version 8.5 because then it would be:

robot --include 'Version_[1-7].*' --include 'Version_8.[1-5]' marques-bruno_1.robot

Hope that’s what you wanted,

Dave.

1 Like