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: Conditional Skip #442

Open
ogmueller opened this issue Aug 31, 2016 · 9 comments
Open

Feature Request: Conditional Skip #442

ogmueller opened this issue Aug 31, 2016 · 9 comments
Labels
Milestone

Comments

@ogmueller
Copy link

Is there any way to skip a class or method based on conditions?

We are writing some benchmarks for PHP functions themselves to actually compare/test servers and setups. The issue we have is, that some environments do not support all of the benchmark subjects. E.g. not all of them have a DB installed, so i would like to automatically skip those tests.

Would it be possible to add a parameter to the "@Skip()"? e.g. a method which will be called and its return value decides about the skip? so "@Skip(noDatabaseAvailable)" would call the method $this->noDatabaseAvailable() and if it returns true, it will be skipped otherwise executed.

@dantleech
Copy link
Member

That sounds like a reasonable approach. Something like @Skip(method="noDatabaseAvailable") and should be quite simple to implement.

Another solution may be to use the --filter option which accepts a regex.

@ogmueller
Copy link
Author

Depending on the situation the filter might be a "painful" solution, because it can end up in a lot of trail and error and could be quite extensive :-) But it can solve this issue as well.

@dantleech
Copy link
Member

Yeah, its not a good solution, just something that might work in some cases. Feel free to make a PR or I can try and have a look in the coming days/weeks as its quite trivial.

@dantleech
Copy link
Member

@ogmueller
Copy link
Author

In our special case groups won't help a lot. But thnx for the hint.

@dantleech dantleech added this to the 1.0 milestone May 19, 2018
@tillkruss
Copy link
Contributor

It would be quite useful to skip benchmarks similar to PHPUnit:

if (! $missingFeature) {
    $this->skipBenchmark('Missing a requirement.');
}

@dantleech
Copy link
Member

That won't work as the benchmark doesn't know anything about PHPBench ... so @Skip(condition-here) where the condition probably needs to be a static method on the class

@tillkruss
Copy link
Contributor

A static method would work 👌

@tillkruss
Copy link
Contributor

@dantleech: @Skip(method="noDatabaseAvailable") would be great. I just ran into this again needing a conditional skip for methods.

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

No branches or pull requests

3 participants