My automated tests (at the GUI/API levels) require to have already existing test data - like users or privileges assigned to them. I want them to be stable and able to run independently every time so I cannot hardcode this data. Also, I wouldn't like to create them as a part of test as it could make my tests more brittle.

Lets assume that a system is a basic CRUD for books management. I'd like to automate test case like "modify book name". In order to do this, first I need to have already created book and user with privilege to modify it. Similar situation occurs for most of other test cases.

Should I prepare this test data before tests, e.g. using API interface? Or maybe I should mock it somehow?

  • Could you clarify (1) where & how the data is stored (local? remote? SQL server? Embedded DB?), and (2) whether the UI is a browser interface or a client app (and if so what platform)? The platform & architecture are significant to your question, they will enable certain solutions while excluding others.
    – JDM
    Feb 5, 2020 at 14:15

1 Answer 1


I would suggest:

  1. Create all the users and books you need in-suite setup.
  2. Drive your test through data-driven through CSV or JSON
  3. Delete the configuration in suite-tear down

in CSV put in all the details like:

user,privilege, action, resource, expected output

a sample CSV would be:

user,privileg, action, resource, expected output
test1,admin, delete, v1/book/1,successfly deleted
test1,basic, delete, v1/book/1,you don't have enough privillege
test1,basic, get, v1/book/1, Have a nice reading time

In this case, your test is driven through CSV you don't have to do anything in test because privilege, expected message, character everything is defined in CSV itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.