Hypothetically, if an automation engineer had to write a test for commenting on a post in a group on Facebook and did not have direct access to the db, but instead to the rest api, the automated test would need:
- A user
- A group
- A post in the group
Since a test should not depend on data from previous tests, should this test create a group, then create a post and then create a comment on the post? Should the same test then delete the comment, delete the post, and delete the group? There are lots of points for potential failures here. What are some best practices for getting an application into the state necessary to perform an atomic automated test? Create and delete the data via the API as part of the test setup and teardown? Something else?