Apotacyll
Apotacyll

Reputation: 85

Start second test only if first test fails in RobotFramework

I got 2 testcases defined in RobotFramework

test1 test2

Is it possible to start test2 only when test1 fails?

Upvotes: 3

Views: 2158

Answers (1)

forkdbloke
forkdbloke

Reputation: 1565

One way of achieving this is by making use of robotframework-dependencylibrary.

excerpt from this library

Declare dependencies between tests. Make tests automatically fail based on the results of other test cases or test suites.

In the below example, you can make use of "Depends on test" keyword as shown.

*** Settings ***
Library  DependencyLibrary

*** Test cases ***
Passing Test
    No operation

Failing Test
    Fail  This test is intentionally hardcoded to fail

This Test Depends on "Passing Test" Passing
    Depends on test  Passing Test
    Log  The rest of the keywords in this test will run as normal.

This Test Depends on "Failing Test" Failing
    Depends on test failure  Failing Test
    Log  The rest of the keywords in this test will run as normal.

Upvotes: 5

Related Questions