Skip to content

[Question] - What is the beforeAll hook best practice - data preparation when duplicate data is not allowed #12314

@hananmalka

Description

@hananmalka

Hi,

I read that if one of the tests in a suite fails - the beforeAll hook is running again (As the worker disposed)

I have a case when my beforeAll hook used for a data preparation using API calls.
In addition, my application has a limitation that I can't create a duplication of an entity.

As mentioned, if one of the tests in a suite failed - beforeAll hook is running again and due to the duplication limitation, the beforeAll hook failed and all tests failed accordingly as well.

I was wonder what could be the best practice in such case?
Currently I implemented it using a fixture which is called only from the first test in the suite, but I feel it's not the best practice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions