RobotFramework:1个测试用例,但有几个结果。如何应对?

RobotFramework:1个测试用例,但有几个结果。如何应对?,robotframework,Robotframework,我有一个包含测试用例的文件。。像这样: *** Settings *** Documentation AREALVALID_LOGINbug4.ROBOT FILE ... ... ese tests are data-driven by their nature. They use a single ... keyword, specified with Test Template setting, that is called ...

我有一个包含测试用例的文件。。像这样:

   *** Settings ***
Documentation     AREALVALID_LOGINbug4.ROBOT FILE    
...    
...    ese tests are data-driven by their nature. They use a single    
...    keyword, specified with Test Template setting, that is called    
...    with different arguments to cover different scenarios.    
...    
...    This suite also demonstrates using setups and teardowns in    
...    different levels.
Suite Setup       Open Browser To Login Page
Suite Teardown    Close Browser
Test Setup        Go To Login Page
Test Template     Login With Invalid Credentials Should Fail
Resource          validresourcebug4.robot

*** Test Cases ***               USER NAME        PASSWORD
testbug4a 16                        ${VALID USER}       14
testbug4a 17                        ${VALID USER}       17   

*** Keywords ***
Login With Invalid Credentials Should Fail
    [Arguments]    ${username}    ${password}
    Input Voedselnaam    ${username}
    Input Password    ${password}
    Submit Credentials
    Check Messages
    Set Browser Implicit Wait    1
    #    Wait Until Element Is Visible    test
    Login Should Have Failed

Login Should Have Failed
    Location Should Be    ${LOGIN URL}
    Title Should Be    Voedsel toevoegen
    Set Browser Implicit Wait    5
我有一个资源文件,看起来是这样的:

 *** Settings ***
Documentation     A resource file with reusable keywords and variables.
...
...               The system specific keywords created here form our own
...               domain specific language. They utilize keywords provided
...               by the imported SeleniumLibrary.
Library           SeleniumLibrary

*** Variables ***
#localhost:7272
${SERVER}                 testenvansoftware.nl/test/invoegenvoedselbug4.php
${BROWSER}                Firefox
${DELAY}                  0
${VALID USER}             90
${VALID PASSWORD}         60
${EIWIT}                  70
${VET}                    15
${LOGIN URL}      http://${SERVER}
${WELCOME URL}    http://${SERVER}/welcome.html
${ERROR URL}      http://${SERVER}/error.html

*** Keywords ***
Open Browser To Login Page
    Open Browser    ${LOGIN URL}    ${BROWSER}
    Maximize Browser Window
    Set Browser Implicit Wait    5
    Set Selenium Speed    ${DELAY}
    Login Page Should Be Open

Login Page Should Be Open
    Title Should Be    Voedsel toevoegen

Go To Login Page
    Go To    ${LOGIN URL}
    Login Page Should Be Open

Input Voedselnaam
    [Arguments]    ${username} 
    Input Text    voedselnaam    ${username}

Input Password
    [Arguments]    ${password}
    Input Text    Eenheid       ${password}
    Input Text    Kcal          ${password}
    Input Text    Eiwit         ${password}
    Input Text    Koolh         ${password}
    Input Text    Vet           ${password}

Submit Credentials
    Click Element   getdata
    Set Browser Implicit Wait    2

Check Messages
    Element Should Be Visible         //label[@class='err']      You       
    Element Text Should Be            //label[@class='err']      You found bug#3: The system crashes by testing this way. Great Job!
    Element Should Contain            //label[@class='err']      You        

Welcome Page Should Be Open
    Location Should Be    ${LOGIN URL}
    Title Should Be    Voedsel toevoegen
    Set Browser Implicit Wait    5
现在,如果password的值为14,则消息与值为17的情况不同

那么最好的解决方案是什么?设置的最佳方式是什么

我应该构建2.robot测试文件吗? 或 我应该建立2个资源文件吗? 或 是否可能在1种情况下检查消息A,在第2种情况下检查消息B?请给出一些建议……

很难准确理解问题所在,但是如果您正在测试不同的输入会产生不同的错误,我建议将预期的错误字符串作为测试的一部分

例如:

*** Test Cases ***       USER NAME        PASSWORD    EXPECTED ERROR
testbug4a 16             ${VALID USER}    14          You found bug #1 blah blah
testbug4a 17             ${VALID USER}    17          You found bug #2 yada yada

这是太多的代码,无法尝试涉过。您能否创建一个尽可能少的代码来说明您遇到的问题?