Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Could we introduce a new context for ordered tests? #735

Open
StarlightIbuki opened this issue Feb 19, 2024 · 11 comments
Open

Comments

@StarlightIbuki
Copy link
Contributor

StarlightIbuki commented Feb 19, 2024

For example:

step("connect to server", function()
  -- ...
end)

step("send requests", function()
  -- ...
end)

The second test should happen after the first no matter what arguments are given, and the second is skipped when the first is failed/skipped.

I know the same behavior can be achieved by putting them into the same it() block, but:

  1. It will only be counted as 1 test in the summary;
  2. it won't benefit from before_each() etc.
@alerque
Copy link
Member

alerque commented Feb 21, 2024

Are tests not run in order now? The flag --sort-tests already defaults to off, and currently we have no parallelization, all all tests are done one at a time in order. Is --no-keep-going what you are looking for? Skipping can be handled by tagging related tests with the same tag to skip.

All this isn't to say we can't consider adding such a feature, but without having threading in the first place it seems like kind of a moot point, no?

@StarlightIbuki
Copy link
Contributor Author

@alerque The idea is that this context keeps its order even when we set --sort-tests or --shuffle to true, and persists in its behavior when --keep-going is true. After all, we see more clear intentions with explicit statements.

@StarlightIbuki
Copy link
Contributor Author

And no, it's not the same to use --no-keep-going. I want it to skip its siblings but not other subsequent tests.

@alerque
Copy link
Member

alerque commented Feb 21, 2024

Is it possible to achieve your dependency situation by nesting existing blocks?

@StarlightIbuki
Copy link
Contributor Author

@alerque No given what I read in the doc.

@Tieske
Copy link
Member

Tieske commented Feb 25, 2024

How would this work if one selects only a single test from a list of steps, using a --tag for example? something to cater for or would that be a user error? (and should it be called out as such?)

@StarlightIbuki
Copy link
Contributor Author

@Tieske It should be a user error I guess? Or simply make it skipped due to the dependency?

@alerque
Copy link
Member

alerque commented Feb 26, 2024

I would imagine the "test" unit that would be skipped / tagged would be whatever is above the steps, not the steps themselves.

@alerque
Copy link
Member

alerque commented Feb 26, 2024

I probably won't be able to work on this any time soon, but I would try to facilitate a PR is somebody else did.

@Tieske
Copy link
Member

Tieske commented Feb 27, 2024

@StarlightIbuki busted has been modeled after some other frameworks, how was this case handled there? That might give some pointers as to how to solve it.

(this case is quite fundamental to how Busted works, hence asking)

@StarlightIbuki
Copy link
Contributor Author

@StarlightIbuki busted has been modeled after some other frameworks, how was this case handled there? That might give some pointers as to how to solve it.

(this case is quite fundamental to how Busted works, hence asking)

Hmmm. Good point. I did not think much before. I remember some of the frameworks make some assertions grouped as a "test point", which needs to be all passed to count for one success test point, and they are just a part of the test flow.
Some of the test frameworks explicitly claim the dependency of a test (like with the notation "@depend.before(test1)").
And for some of the frameworks, this is simply not considered. I guess we have some freedom on how to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants