Section 2
Cours 2.1 - Suite de tests, cas de test et mots-clés utilisateur
Test Suite - Comme expliqué dans L-1.5, nous pouvons créer une Test Suite sous un
projet. Une suite de tests , en général, est une collection de cas de test.
Une suite de tests peut être enregistrée en tant que fichier .robot, fichier .txt ou
fichier .tsv. Vous pouvez suivre n'importe lequel et l'utiliser dans votre projet.
Dans RIDE, il apparaît comme ceci
Configuration de la suite de tests
1. Importations A. Bibliothèques B. Ressources c. variables
2. Ajouter un nouveau A. Scalaire b. Liste c. Dictionnaire D. Métadonnées
3. Paramètres A. Documents B. Configuration de la suite c. Démontage de la suite
d. Configuration du test e. Essai de démontage f. Modèle de test g. Délai
d'expiration du test h. Forcer les balises i. Balises par défaut
Les configurer sur RIDE est très facile car son interface est très conviviale.
En RED, vous devez aller dans l'éditeur et cliquer sur Ctrl + Espace. Lorsque vous
double-cliquez sur Paramètres, tout cela apparaîtra.
Nous verrons plus de détails à ce sujet plus tard.
Cas de test -
Un cas de test simple dans le cadre du robot ressemble à ceci. Il comporte une ou
plusieurs étapes les unes après les autres. Par souci de simplicité, nous enregistrons
simplement le message sur la console.
TC2
Log test message 1
Log test message 2
Log test message 3
Passons au test suivant où nous convertissons la température Celsius en
Fahrenheit. C'est absolument correct, si vous ne comprenez pas le code ci-dessous et
sa sortie. Jetez un coup d'œil à la façon dont nous écrivons des cas de test dans le
cadre du robot.
*** Test Cases ***
TC5
[Documentation] Test to convert celcius to fahrenheit
${celcius}= Set Variable 37
${fahrenheit}= Evaluate (${celcius}*9/5)+32
Log ${fahrenheit}
TC6
[Documentation] Test to convert List of celcius values to fahrenheit
@{celcius}= Create List 10 12 37 22
FOR ${temp} IN @{celcius}
${fahrenheit}= Evaluate (${temp}*9/5)+32
Log ${fahrenheit}
END
Journaux de sortie
Starting test: Project1.TS1.TC5
20191207 [Link].743 : INFO : ${celcius} = 37
20191207 [Link].743 : INFO : ${Farehneit} = 98.6
20191207 [Link].743 : INFO : 98.6
Ending test: Project1.TS1.TC5
Starting test: Project1.TS1.TC6
20191207 [Link].743 : INFO : @{celcius} = [ 10 | 12 | 37 | 22 ]
20191207 [Link].743 : INFO : ${Farehneit} = 50.0
20191207 [Link].743 : INFO : 50.0
20191207 [Link].743 : INFO : ${Farehneit} = 53.6
20191207 [Link].743 : INFO : 53.6
20191207 [Link].743 : INFO : ${Farehneit} = 98.6
20191207 [Link].743 : INFO : 98.6
20191207 [Link].743 : INFO : ${Farehneit} = 71.6
20191207 [Link].743 : INFO : 71.6
Ending test: Project1.TS1.TC6
Mots-clés de l'utilisateur -
Les mots-clés utilisateur ne sont rien d'autre que des fonctions si l'on compare avec
les langages de programmation. Nous utilisons des fonctions pour rendre le code
modulaire. De la même manière, les mots-clés utilisateur dans le cadre du robot sont
destinés à servir cet objectif.
*** Test Cases ***
TC1
Function1
Run Keyword Function2
*** Keywords ***
Function1
Log This is a inner function1
Function2
Log This is a inner function2
Un autre exemple est illustré ci-dessous. Ici, nous avons 4 cas de test (TC1, TC2, TC3,
TC4) et 2 mots-clés utilisateur (CommonFunction1, CommonFunction2). Nous
pouvons appeler des mots-clés utilisateur à partir de cas de test, comme indiqué
dans TC3 et TC4.
*** Keywords ***
CommonFunction1
Log test message 1
Log test message 2
Log test message 3
CommonFunction2
[Arguments] ${msg1} ${msg2} ${msg3}
Log ${msg1}
Log ${msg2}
Log ${msg3}
*** Test Cases ***
TC1
Log test message 1
Log test message 2
Log test message 3
TC2
Log test message 1
Log test message 2
Log test message 3
TC3
[Documentation] Test having User keyword without arguments
CommonFunction1
TC4
[Documentation] Test having User keyword with arguments
CommonFunction2 test message 1 test message 2 test message 3
PARAMÈTRES AU NIVEAU DE LA SUITE
*** Settings ***
Documentation this is suite level documentation
Suite Setup Log Suite begins
Suite Teardown Log Suite Ends
Test Setup Log test setup 1
Test Teardown Log test teardown 1
PARAMÈTRES DE NIVEAU DE TEST
[Documentation] this is test level documentation
[Setup] Log test setup 2
[Teardown] Log test teardown 2
REMARQUE : Si nous avons Test Setup/Teardown au niveau de la suite
et SETUP/TEARDOWN au niveau du test, les
méthodes SETUP/TEARDOWN remplacent les méthodes Test Setup/Teardown .
Cours 2.2 - Bibliothèque intégrée et mots-clés
Variables locales et globales
1. Définir la variable
TC1
${a}= Set Variable 50
2. Définir la variable si
TC2
${a}= Set Variable If True==True 50 100
Log ${a}
TC3
${a}= Set Variable If True==False 50 100
Log ${a}
Sortir:
20191208 [Link].433 : INFO : ${a} = 50
20191208 [Link].434 : INFO : 50
Ending test: Project1.TS1.TC2
Starting test: Project1.TS1.TC3
20191208 [Link].436 : INFO : ${a} = 100
20191208 [Link].438 : INFO : 100
3. Définir la variable globale
TC4 - Set Global Variable
${a}= Set Variable 50
Set Global Variable ${a}
Désormais, la variable a est globale et peut être utilisée de n'importe où tout au long
de l'exécution.
Type de données/Système de numération Conversion
4. Convertir en binaire
TC5 - Convert To Binary
${a}= Set Variable 99
${b}= Convert To Binary ${a}
Log ${b}
Sortir:
Starting test: [Link].TC5 - Convert To Binary
20191212 [Link].040 : INFO : ${a} = 99
20191212 [Link].041 : INFO : ${b} = 1100011
20191212 [Link].042 : INFO : 1100011
5. Convertir en booléen
Cette fonction est utilisée pour gérer vrai et faux sensibles à la casse et convertir en
une valeur booléenne.
TC6 - Convert To Boolean
${a}= Set Variable tRuE
${b}= Convert To Boolean ${a}
Log ${b}
Starting test: [Link].TC6 - Convert To Boolean
20191212 [Link].294 : INFO : ${a} = tRuE
20191212 [Link].294 : INFO : ${b} = True
20191212 [Link].295 : INFO : True
6. Convertir en octets
TC7 - Convert To Bytes
${b}= Convert To Bytes 75 65 77 65 76 int
Log ${b}
Sortir:
20191212 [Link].323 : INFO : ${b} = KAMAL
20191212 [Link].324 : INFO : KAMAL
7. Convertir en hexadécimal
TC8 - Convert To Hex
${b}= Convert To Hex 100 10
${b}= Convert To Hex 100 8
Sortir:
20191212 [Link].941 : INFO : ${b} = 64
20191212 [Link].941 : INFO : ${b} = 40
8. Convertir en entier
TC9 - Convert To Integer
${b}= Convert To Integer FF 16
${b}= Convert To Integer 100 8
Sortir:
20191212 [Link].501 : INFO : ${b} = 255
9. Convertir en nombre
TC10 - Convert To Number
${b}= Convert To Number 41.111 1
Sortir:
20191212 [Link].088 : INFO : ${b} = 41.1
10. Convertir en octal
TC11 - Convert To Octal
${b}= Convert To Octal 111 2
Sortir:
20191212 [Link].408 : INFO : ${b} = 7
11. Définir le niveau de journalisation
TC13 - Info Logs
Set Log Level INFO
Log this is Info Log INFO
Log <h1>this is HTML Log</h1> HTML
Log this is WARN Log WARN
Log this is ERROR Log ERROR
Log this is DEBUG Log DEBUG
TC14 - Debug and Trace Logs
Set Log Level DEBUG
${a}= Set Variable 100
Par défaut, seuls les journaux d'informations sont imprimés sur la console. Pour
imprimer les journaux de débogage, nous devons définir le niveau de journalisation
sur DEBUG. Pour les journaux de niveau de trace, nous devons le définir sur TRACE.
Il y a beaucoup d'autres fonctions dans la bibliothèque intégrée. Nous verrons leur
utilisation plus tard lors de l'écriture de tests réels.
13. Fonctions d'informations Suite/Test
Set Suite Documentation
Set Suite Metadata
Set Suite Variable
Set Tags
Set Test Documentation
Set Test Message
14. Fonctions journaux et commentaires
Comment
Log
Log Many
Log To Console
Log Variables
15. Fonctions d'assertion
Length Should Be
Should Be Empty
Should Be Equal
Should Be Equal As Integers
Should Be Equal As Numbers
Should Be Equal As Strings
Should Be True
Should Contain
Should Contain Any
Should Contain X Times
Should End With
Should Match
Should Match Regexp
Should Not Be Empty
Should Not Be Equal
Should Not Be Equal As Integers
Should Not Be Equal As Numbers
Should Not Be Equal As Strings
Should Not Be True
Should Not Contain
Should Not Contain Any
Should Not End With
Should Not Match
Should Not Match Regexp
Should Not Start With
Should Start With
Variable Should Exist
Variable Should Not Exist
16. Fonctions de boucle
Continue For Loop
Continue For Loop If
Exit For Loop
Exit For Loop If
17. Fonctions d'importation
Import Library
Import Resource
Import Variables
18. Mots clés de contrôle d'exécution
Call Method
Keyword Should Exist
Return From Keyword
Return From Keyword If
Run Keyword
Run Keyword And Continue On Failure
Run Keyword And Expect Error
Run Keyword And Ignore Error
Run Keyword And Return
Run Keyword And Return If
Run Keyword And Return Status
Run Keyword If
Run Keyword If All Critical Tests Passed
Run Keyword If All Tests Passed
Run Keyword If Any Critical Tests Failed
Run Keyword If Any Tests Failed
Run Keyword If Test Failed
Run Keyword If Test Passed
Run Keyword If Timeout Occurred
Run Keyword Unless
Run Keywords
Repeat Keyword
Wait Until Keyword Succeeds
Sleep
19. Autres fonctions importantes
Get Count
Get Length
Get Time
Get Variable Value
Get Variables
Catenate
Evaluate
Fail
No Operation
Pass Execution
Pass Execution If
Fatal Error
Regexp Escape
Remove Tags
Set Variable
Cours 2.3 - Scalaires, listes, dictionnaires et fichiers variables
Scalaires
L'ajout d'un scalaire dans la vue de la table RIDE ressemble à ceci.
Et vous pouvez ajouter un scalaire en ROUGE de cette manière.
*** Variables ***
${scalar1} 10
${scalar2} Hello World
*** Test Cases ***
TC1 - Use Scalars
${sum}= Evaluate ${scalar1}+100
Sortir
20191212 [Link].678 : INFO : ${sum} = 110
Listes
*** Variables ***
@{list1} Sun Mon Tue Wed Thu Fri Sat
*** Test Cases ***
TC1
Log ${list1[3]}
Sortir
20191212 [Link].738 : INFO : Wed
Dictionnaires
*** Variables ***
&{dict1} jan=1 feb=2 mar=3 apr=4 may=5 jun=6
*** Test Cases ***
TC1
Log ${dict1['mar']}
Sortir
20191212 [Link].167 : INFO : 3
Pour créer des scalaires, des listes et des dictionnaires, nous pouvons également
utiliser des mots-clés :
Set Variable
Set Variable If
Set Global Variable
Set Test Variable
Create List
Create Dictionary
*** Test Cases ***
TC1
@{list2}= Create List 1 2 3 4
Log ${list2[2]}
TC2
&{dict2}= Create Dictionary a=1 b=2 c=3 d=4
Log ${dict2['c']}
Fichiers variables
*** Settings ***
Variables [Link]
TC3
Log ${firstname}${space}${lastname}
where config file ([Link]) has
firstname="Kamal"
lastname="Girdher"
profile="trainer"
Sortir
20191212 [Link].123 : INFO : Kamal Girdher
Cours 2.4 - Démontage de la configuration Suite/Test
*** Settings ***
Suite Setup suite_setup
Suite Teardown suite_teardown
Test Setup test_setup
Test Teardown test_teardown
*** Test Cases ***
TC1
Log 1
TC2
Log 2
TC3
Log 3
*** Keywords ***
suite_setup
Log SETUP SUITE
suite_teardown
LOG SUITE ENDS
test_setup
LOG TEST START
test_teardown
Log TEST ENDS
Sortir
20191212 [Link].049 : INFO : SETUP SUITE
Starting test: [Link].TC1
20191212 [Link].052 : INFO : TEST START
20191212 [Link].055 : INFO : 1
20191212 [Link].056 : INFO : TEST ENDS
Ending test: [Link].TC1
Starting test: [Link].TC2
20191212 [Link].059 : INFO : TEST START
20191212 [Link].060 : INFO : 2
20191212 [Link].061 : INFO : TEST ENDS
Ending test: [Link].TC2
Starting test: [Link].TC3
20191212 [Link].063 : INFO : TEST START
20191212 [Link].064 : INFO : 3
20191212 [Link].066 : INFO : TEST ENDS
Ending test: [Link].TC3
20191212 [Link].067 : INFO : SUITE ENDS
Certains mots-clés peuvent être utilisés dans le démontage de la suite.
Run Keyword If All Critical Tests Passed
Run Keyword If All Tests Passed
Run Keyword If Any Critical Tests Failed
Run Keyword If Any Tests Failed
Avant d'utiliser les mots clés pour se comporter d'une certaine manière pour les tests
critiques ou non critiques, il est important de savoir comment nous marquons les
tests CRITIQUES ou NON CRITIQUES dans le cadre du robot.
Pour marquer les tests comme critiques, utilisez des balises pour différencier les
tests. Lors de l'exécution, vous devez utiliser --critical ou --noncritical .
Par exemple, dans le code ci-dessous, j'ai utilisé la balise critique pour TC1 et
TC3. Lorsque j'exécute des tests normalement, tous les tests sont considérés comme
critiques par défaut. Mais si je veux que seuls les cas de test avec la balise "critical"
soient considérés comme critiques, je dois exécuter avec des arguments --critical
critical
Faites un clic droit sur la suite de tests, cliquez sur Exécuter en tant que> Exécuter les
configurations .. et mettez ces arguments "--critical critical"
*** Settings ***
Suite Setup suite_setup
Suite Teardown suite_teardown
Test Setup test_setup
Test Teardown test_teardown
*** Test Cases ***
TC1
[Tags] critical
Log 1
TC2
[Tags] non-critical
Log 2
Fail
TC3
[Tags] critical
Log 3
*** Keywords ***
suite_setup
Log SuiteStarts
suite_teardown
Run Keyword If All Critical Tests Passed UserKeyword4
LOG SUITE ENDS
test_setup
LOG TEST START
test_teardown
Log TEST ENDS
UserKeyword4
Log All critical tests passed
Sortir
20191213 [Link].727 : INFO : SuiteStarts
Starting test: Project2.1.006 SetupAndTearDownFunctions.TC1
20191213 [Link].729 : INFO : TEST START
20191213 [Link].730 : INFO : 1
20191213 [Link].731 : INFO : TEST ENDS
Ending test: Project2.1.006 SetupAndTearDownFunctions.TC1
Starting test: Project2.1.006 SetupAndTearDownFunctions.TC2
20191213 [Link].733 : INFO : TEST START
20191213 [Link].734 : INFO : 2
20191213 [Link].735 : FAIL : AssertionError
20191213 [Link].737 : INFO : TEST ENDS
Ending test: Project2.1.006 SetupAndTearDownFunctions.TC2
Starting test: Project2.1.006 SetupAndTearDownFunctions.TC3
20191213 [Link].739 : INFO : TEST START
20191213 [Link].740 : INFO : 3
20191213 [Link].741 : INFO : TEST ENDS
Ending test: Project2.1.006 SetupAndTearDownFunctions.TC3
20191213 [Link].743 : INFO : All critical tests passed
20191213 [Link].744 : INFO : SUITE ENDS
Voir l'avant-dernière ligne de la sortie "Tous les tests critiques ont
réussi". Maintenant, vous pouvez facilement essayer trois autres mots-clés.
Certains mots-clés sont destinés au démontage des tests.
Run Keyword If Test Failed
Run Keyword If Test Passed
Run Keyword If Timeout Occurred
Tout cela s'explique d'eux-mêmes. Si vous avez besoin de plus d'informations à ce
sujet, écrivez-moi.
Cours 2.5 - Ressources externes
L'ajout d'un fichier de ressources est très simple. Cela peut être fait en cliquant avec
le bouton droit sur le projet et en sélectionnant Nouveau> Fichier de ressources
robot en ROUGE. Et dans RIDE en cliquant simplement sur Nouvelle ressource.
Une ressource est plus ou moins similaire à une suite de tests. La seule différence est
que nous n'écrivons pas de cas de test dans les fichiers de ressources. Cependant,
nous écrivons des fonctions réutilisables (appelées mots-clés utilisateur) et nous
définissons des scalaires, des listes et des dictionnaires spécifiques à cette ressource.
Dans le projet 2.1, [Link] est une ressource qui est importée dans la suite
de tests 006_SuiteImportingResource.robot
[Link]
*** Keywords ***
UserKeyword1
Log This is keyword 1
UserKeyword2
Log This is keyword 2
Nous pouvons exécuter les mots-clés du fichier de ressources en utilisant directement
le nom du mot-clé ou en utilisant un autre mot-clé intégré "Run Keyword".
006_SuiteImportingResource.robot
*** Settings ***
Resource [Link]
*** Test Cases ***
TC1
Run Keyword UserKeyword1
UserKeyword1
Sortir
Starting test: Project2.1.006 SuiteImportingResource.TC1
20191213 [Link].779 : INFO : This is keyword 1
20191213 [Link].780 : INFO : This is keyword 1
Ending test: Project2.1.006 SuiteImportingResource.TC1
Nous avons utilisé la fonction intégrée "Exécuter le mot-clé" pour exécuter notre
mot-clé défini par l'utilisateur. Revenons à la section 2.2, point #18 "Fonctions de
contrôle d'exécution"
Call Method
Keyword Should Exist
Return From Keyword
Return From Keyword If
Run Keyword
Run Keyword And Continue On Failure
Run Keyword And Expect Error
Run Keyword And Ignore Error
Run Keyword And Return
Run Keyword And Return If
Run Keyword And Return Status
Run Keyword If
Run Keyword If All Critical Tests Passed
Run Keyword If All Tests Passed
Run Keyword If Any Critical Tests Failed
Run Keyword If Any Tests Failed
Run Keyword If Test Failed
Run Keyword If Test Passed
Run Keyword If Timeout Occurred
Run Keyword Unless
Run Keywords
Repeat Keyword
Wait Until Keyword Succeeds
Sleep
Maintenant, vous pouvez facilement voir que nous pouvons utiliser plusieurs de ces
fonctions de différentes manières. Vous pouvez les explorer. Nous couvrirons plus de
la liste dans nos prochaines sections.
Cours 2.6 - Instructions de boucle
Test
TC1 - For loop using range
:FOR ${i} IN RANGE 1 10
\ Log ${i}
Sortir
Starting test: Project2.1.007 LoopStatements.TC1 - For loop using range
20191213 [Link].610 : INFO : 1
20191213 [Link].611 : INFO : 2
20191213 [Link].612 : INFO : 3
20191213 [Link].613 : INFO : 4
20191213 [Link].614 : INFO : 5
20191213 [Link].614 : INFO : 6
20191213 [Link].615 : INFO : 7
20191213 [Link].616 : INFO : 8
20191213 [Link].617 : INFO : 9
Ending test: Project2.1.007 LoopStatements.TC1 - For loop using range
Test
TC2 - For loop using range - with correct upper bound
:FOR ${i} IN RANGE 1 11
\ Log ${i}
Sortir
Starting test: Project2.1.007 LoopStatements.TC2 - For loop using range - with
correct upper bound
20191213 [Link].619 : INFO : 1
20191213 [Link].620 : INFO : 2
20191213 [Link].621 : INFO : 3
20191213 [Link].623 : INFO : 4
20191213 [Link].623 : INFO : 5
20191213 [Link].624 : INFO : 6
20191213 [Link].625 : INFO : 7
20191213 [Link].625 : INFO : 8
20191213 [Link].626 : INFO : 9
20191213 [Link].628 : INFO : 10
Ending test: Project2.1.007 LoopStatements.TC2 - For loop using range - with
correct upper bound
Test
TC3 - For loop using a list
@{a}= Create List 1 2 3 4 5
:FOR ${i} IN @{a}
\ Log ${i}
Sortir
Starting test: Project2.1.007 LoopStatements.TC3 - For loop using a list
20191213 [Link].630 : INFO : @{a} = [ 1 | 2 | 3 | 4 | 5 ]
20191213 [Link].630 : INFO : 1
20191213 [Link].631 : INFO : 2
20191213 [Link].632 : INFO : 3
20191213 [Link].633 : INFO : 4
20191213 [Link].634 : INFO : 5
Ending test: Project2.1.007 LoopStatements.TC3 - For loop using a list
Test
TC4 - Exit for loop in between
@{a}= Create List 1 2 3 4 5
:FOR ${i} IN @{a}
\ Log ${i}
\ Exit For Loop
TC5 - Conditional Exit from For Loop
@{a}= Create List 1 2 3 4 5
:FOR ${i} IN @{a}
\ Exit For Loop If ${i}>3
\ Log ${i}
Sortir
Starting test: Project2.1.007 LoopStatements.TC4 - Exit for loop in between
20191213 [Link].635 : INFO : @{a} = [ 1 | 2 | 3 | 4 | 5 ]
20191213 [Link].636 : INFO : 1
20191213 [Link].637 : INFO : Exiting for loop altogether.
Ending test: Project2.1.007 LoopStatements.TC4 - Exit for loop in between
Starting test: Project2.1.007 LoopStatements.TC5 - Conditional Exit from For Loop
20191213 [Link].638 : INFO : @{a} = [ 1 | 2 | 3 | 4 | 5 ]
20191213 [Link].641 : INFO : 1
20191213 [Link].642 : INFO : 2
20191213 [Link].643 : INFO : 3
20191213 [Link].645 : INFO : Exiting for loop altogether.
Ending test: Project2.1.007 LoopStatements.TC5 - Conditional Exit from For Loop
Test
TC6 - New FOR END loop Syntax from robotframework v > 3.2
FOR ${i} IN RANGE 1 11
Log ${i}
END
Sortir
Starting test: Project2.1.007 LoopStatements.TC6 - New FOR END loop Syntax from
robotframework v > 3.2
20191213 [Link].646 : INFO : 1
20191213 [Link].647 : INFO : 2
20191213 [Link].649 : INFO : 3
20191213 [Link].649 : INFO : 4
20191213 [Link].650 : INFO : 5
20191213 [Link].651 : INFO : 6
20191213 [Link].652 : INFO : 7
20191213 [Link].652 : INFO : 8
20191213 [Link].653 : INFO : 9
Ending test: Project2.1.007 LoopStatements.TC6 - New FOR END loop Syntax from
robotframework v > 3.2
Cours 2.7 - Fonctions conditionnelles
Contrairement à tout langage de programmation, il n'y a pas d'instruction If..Else ou
Switch..Case dans le cadre du robot. Cependant, il existe un ensemble de fonctions
qui sont utilisées pour implémenter la logique conditionnelle dans les pur tests.
Voici la liste des fonctions dont je parle.
Set Variable If
Get Variable Value
Run Keyword If
Run Keyword Unless
Continue For Loop If
Exit For Loop If
Pass Execution If
Return From Keyword If
Run Keyword And Return If
Run Keyword If All Critical Tests Passed
Run Keyword If All Tests Passed
Run Keyword If Any Critical Tests Failed
Run Keyword If Any Tests Failed
Run Keyword If Test Failed
Run Keyword If Test Passed
Run Keyword If Timeout Occurred
*** Settings ***
Resource [Link]
*** Test Cases ***
TC1 - Set Variable If
#If condition returns true
${cond}= Set Variable True
${a}= Set Variable If ${cond}==True 10
Log ${a}
#If condition returns false
${a}= Set Variable If ${cond}==False 10 0
Log ${a}
TC2 - Run Keyword If
${cond}= Set Variable True
Run Keyword If ${cond}==True UserKeyword1 ELSE UserKeyword2
TC3 - Run Keyword Unless
FOR ${i} IN RANGE 1 10
Log ------
Run Keyword Unless ${i}>5 Log Iteration=${i}
END
TC4 - Continue For Loop If
FOR ${i} IN RANGE 1 10
Log Starting ${i}
Continue For Loop If ${i}>5
Log Ending ${i}
END
TC5 - Exit For Loop If
FOR ${i} IN RANGE 1 10
Log Starting ${i}
Exit For Loop If ${i}>5
Log Ending ${i}
END
TC6 - Pass Execution If
${i}= Set Variable 10
Pass Execution If ${i}>5 Passing the execution
Fail Forcefully failing the test
TC7 - Return From Keyword If
${b}= Userkeyword3
#TC8 - Run Keyword And Return If
#we will see the usage later
*** Keywords ***
Userkeyword3
${a}= Set Variable 10
Return From Keyword If ${a}<5 Hello
Return From Keyword If ${a}>5 Hi
Sortir
Starting test: Project2.1.008 ConditionalFunctions.TC1 - Set Variable If
20191213 [Link].828 : INFO : ${cond} = True
20191213 [Link].828 : INFO : ${a} = 10
20191213 [Link].828 : INFO : 10
20191213 [Link].828 : INFO : ${a} = 0
20191213 [Link].828 : INFO : 0
Ending test: Project2.1.008 ConditionalFunctions.TC1 - Set Variable If
Starting test: Project2.1.008 ConditionalFunctions.TC2 - Run Keyword If
20191213 [Link].828 : INFO : ${cond} = True
20191213 [Link].828 : INFO : This is keyword 1
Ending test: Project2.1.008 ConditionalFunctions.TC2 - Run Keyword If
Starting test: Project2.1.008 ConditionalFunctions.TC3 - Run Keyword Unless
20191213 [Link].828 : INFO : ------
20191213 [Link].828 : INFO : Iteration=1
20191213 [Link].828 : INFO : ------
20191213 [Link].828 : INFO : Iteration=2
20191213 [Link].828 : INFO : ------
20191213 [Link].844 : INFO : Iteration=3
20191213 [Link].844 : INFO : ------
20191213 [Link].844 : INFO : Iteration=4
20191213 [Link].844 : INFO : ------
20191213 [Link].844 : INFO : Iteration=5
20191213 [Link].844 : INFO : ------
20191213 [Link].844 : INFO : ------
20191213 [Link].844 : INFO : ------
20191213 [Link].844 : INFO : ------
Ending test: Project2.1.008 ConditionalFunctions.TC3 - Run Keyword Unless
Starting test: Project2.1.008 ConditionalFunctions.TC4 - Continue For Loop If
20191213 [Link].844 : INFO : Starting 1
20191213 [Link].844 : INFO : Ending 1
20191213 [Link].844 : INFO : Starting 2
20191213 [Link].844 : INFO : Ending 2
20191213 [Link].844 : INFO : Starting 3
20191213 [Link].844 : INFO : Ending 3
20191213 [Link].860 : INFO : Starting 4
20191213 [Link].860 : INFO : Ending 4
20191213 [Link].860 : INFO : Starting 5
20191213 [Link].860 : INFO : Ending 5
20191213 [Link].860 : INFO : Starting 6
20191213 [Link].860 : INFO : Continuing for loop from the next iteration.
20191213 [Link].860 : INFO : Starting 7
20191213 [Link].860 : INFO : Continuing for loop from the next iteration.
20191213 [Link].860 : INFO : Starting 8
20191213 [Link].860 : INFO : Continuing for loop from the next iteration.
20191213 [Link].860 : INFO : Starting 9
20191213 [Link].860 : INFO : Continuing for loop from the next iteration.
Ending test: Project2.1.008 ConditionalFunctions.TC4 - Continue For Loop If
Starting test: Project2.1.008 ConditionalFunctions.TC5 - Exit For Loop If
20191213 [Link].860 : INFO : Starting 1
20191213 [Link].860 : INFO : Ending 1
20191213 [Link].860 : INFO : Starting 2
20191213 [Link].860 : INFO : Ending 2
20191213 [Link].860 : INFO : Starting 3
20191213 [Link].860 : INFO : Ending 3
20191213 [Link].875 : INFO : Starting 4
20191213 [Link].875 : INFO : Ending 4
20191213 [Link].875 : INFO : Starting 5
20191213 [Link].875 : INFO : Ending 5
20191213 [Link].875 : INFO : Starting 6
20191213 [Link].875 : INFO : Exiting for loop altogether.
Ending test: Project2.1.008 ConditionalFunctions.TC5 - Exit For Loop If
Starting test: Project2.1.008 ConditionalFunctions.TC6 - Pass Execution If
20191213 [Link].875 : INFO : ${i} = 10
20191213 [Link].875 : INFO : Execution passed with message:
Passing the execution
Ending test: Project2.1.008 ConditionalFunctions.TC6 - Pass Execution If
Starting test: Project2.1.008 ConditionalFunctions.TC7 - Return From Keyword If
20191213 [Link].875 : INFO : ${a} = 10
20191213 [Link].875 : INFO : Returning from the enclosing user keyword.
20191213 [Link].875 : INFO : ${b} = Hi
Ending test: Project2.1.008 ConditionalFunctions.TC7 - Return From Keyword If