Skip to content

Control release of ResourceStep #237

@yanns

Description

@yanns

Actually the release of an ResourceStep is called at the end of the scenario.
It can make the release process complex if it needs some other information, like a special OAuthToken.

Idea: a ResourceStep can collect steps.
for example: let's see I need an admin user that is deleted after the tests.
This admin user can create projects.
A scenario could be:

{
  WithAdminUser("root") {
    WithProject("project1") {
      When I get("/projects)
      Then assert body.path("count").is(1)

      WithProject("project2") {
        When I get("/projects)
        Then assert body.path("count").is(2)
      } // `project2` is deleted here

      When I get("/projects)
      Then assert body.path("count").is(1)
    } // `project1` is deleted here
  } // `root` is deleted here
}

And maybe introduce a way to compose such ResourceStep together.

val GivenAdminUserAndProject = WithAdminUser("root").andThen(WithProject("project1"))

{
  GivenAdminUserAndProject {
    When I get("/projects)
    Then assert body.path("count").is(1)
  } // `project1` and `root` are deleted here
}

This could replace beforeEachScenario and  afterEachScenario.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions