Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
810 views
in Technique[技术] by (71.8m points)

robotframework - How Do I return to main page only when one of test within test suite failed?

I have written test suite

test cases as follows:

when one of test case failed, I want the screen back to main page. so next test case can start correctly.

how can I do so? e.g. While executing current test, if previous case failed, then go to main page before start current test. otherwise, proceed current test as usual.

*** Settings ***
Resource            ../Resources/res.robot
Suite Setup         Suite Setup Suite
Test Setup          Test Setup
Suite Teardown      Test Teardown

*** Test Cases ***
TC1
    Launch App
    main page click button A
    Page                   ${TITLE} Test1
    Go Back

TC2
    Launch App
    main page click button A
    Open Page              ${TITLE} Test2
    Go Back

TC3
    Launch App
    main page click button A
    Open Page              ${TITLE} Test3
    Go Back

resource file

Suite Setup Suite
    Test Setup
    Launch Application

Test Teardown
    Log Source
    Close All Applications

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Every test should be independent and not rely on side effects from previous tests. That means that the test setup of each test should be responsible for making sure the home page is the current page.

For example, you can make a keyword named Go to main page, and call that as part of your test setup. That keyword can check the current page, and if it's not the current page then do whatever is necessary to get back to the main page.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...