Status: New
Owner: ----
Labels: Type-Enhancement Priority-Medium

New issue 1710 by bryan.oa...@gmail.com: Add new built-in keyword "Require test case"
http://code.google.com/p/robotframework/issues/detail?id=1710

I would like a new keyword, "Require test case" (or perhaps "Require" or "Depends on") which will fail if the given test case was not run, or was run and failed.

While it's never good to write test cases that depend on other test cases, the reality is that people will sometimes create this situation. By introducing this keyword, these dependencies can be exposed and enforced, and resulting failures will be easier to identify.

For example, imagine the following suite:

    *** Test Cases ***
    | Verify we can create a new account
    | | Create a new account | Foo

    <some other test cases>

    | Verify we can delete a new account
    | | Delete the account | Foo

As written, it's not obvious that the last test depends on the first. If the first test fails, the later one may fail with a message such as "Account foo doesn't exist" which is only half true. Arguably a more useful message would be "Required test case "Verify we can create a new account" failed". This keyword lets you know that the true root cause is the test that creates the account failed. As a bonus, keywords will fail quicker when a dependency isn't met.

With this new keyword, the test case would look like:

    | Verify we can delete a new account
    | | Require test case | Verify we can create a new account
    | | Delete the account | Foo

While not ideal, it at least exposes poor practices rather than sweeping them under the rug.

This keyword is fairly straight forward to implement, all of the data needed to implement it is publicly exposed (depending on how you define "publicly"). I've attached a .py file with my first attempt at writing it. It only supports dependencies within a suite, since dependencies betweens suites should always be strongly discouraged (though inter-suite dependencies could be supported if need be)

While this keyword is easy enough for me to add locally, I think including it to BuiltIn will be useful to others. Plus it guarantees that the keyword it will continue to work if/when the underlying data structures change.

As a bonus, this might help pave the way to a smarter test runner some day -- it could build dependency chains in order to split a test suite into parallel test runs.

Attachments:
        require_test_case.py  1.4 KB

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to