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

skip test with annotation #2875

Closed
mathroc opened this issue Nov 24, 2017 · 5 comments
Closed

skip test with annotation #2875

mathroc opened this issue Nov 24, 2017 · 5 comments

Comments

@mathroc
Copy link

mathroc commented Nov 24, 2017

Q A
PHPUnit version 5.7.23
PHP version 5.6.31
Installation Method Composer

It would be nice to be able to skip test with an annotation, eg @skipTest "needs bla bla bla"
The main advantage with this is that it could skip the setUp/tearDown too and make the test suite a bit faster

@sebastianbergmann sebastianbergmann added the type/enhancement A new idea that should be implemented label Nov 25, 2017
@sebastianbergmann sebastianbergmann removed the type/enhancement A new idea that should be implemented label Dec 6, 2017
@sebastianbergmann
Copy link
Owner

I do not think that this would be useful.

@ob-ivan
Copy link

ob-ivan commented Feb 15, 2018

Also, this would allow to skip data provider too.

In my current project I have a piece of massively tested new functionality. The data provider for a single test method returns some hundreds of data sets. The functionality is already merged into master, but the client asked to disable it temporarily for business-wise reasons. If I use markTestSkipped inside the test method, I get 373 "test is skipped" messsages, each taking at least 5 lines in terminal, pushing any real error reports out from terminal buffer.

What I want is to be able to skip a test without all the useless verboseness. I tried a workaround prepending test method name with disabled_ prefix, then it doesn't get executed, but instead I have "No tests found in class" warning, because the test case contains only one test method.

Adding a "disabled" group to it doesn't work for me too, because the test case already has "functional" group assigned, and when I run phpunit --group=functional it doesn't exclude "disabled" group.

@sebastianbergmann please give it a second thought.

@adrian-enspired
Copy link

this - using markTestSkipped doesn't actually skip the test. it still invokes the test, it still runs the dataproviders, and if you disable those, you get errors because the test is invoked without args.

@epdenouden
Copy link
Contributor

@adrian-enspired thank you for mentioning this, the data providers for skipped tests are on my list for #3736.

->markTestSkipped() follows a different code path and is used for when a developer wants to mark a test skipped from inside the runtime context. The annotation should never invoke the test and its associated fixtures.

@epdenouden
Copy link
Contributor

epdenouden commented Jul 19, 2019

Oops. I just noticed the previous discussion upthread. @sebastianbergmann I will make a @skipTest annotation experiment for the data provider project as a separate pull request, see if can be useful and implemented cleanly.

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

No branches or pull requests

6 participants
@sebastianbergmann @mathroc @adrian-enspired @ob-ivan @epdenouden and others