-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Skipping tests at runtime with GTEST_SKIP() #1544
Conversation
Sure! The key here is ability to skip tests at run-time (based on a run-time condition); this feature is introduced in addition to compile-time disabling, rather than as replacement. Consider a test, which can fail or succeed, but is only supported (i.e. can be executed) when certain condition is met, and testing the condition can only be carried out in run-time; otherwise test is not supported. As of now, there is no pretty way to handle this:
My use-caseTest descriptionConsider a test which validates correctness of hardware-accelerated AES encryption (e.g. with AES-NI); such test can only be executed on processors with support for AES-NI, and it is not known in advance if target machine has such processor. Environment constraintsTests binary is pre-built and distributed onto several target machines, and none of target machines have C++ compiler installed. Solution with
|
@aprelev Thank you for the explanation. We had a bit of internal discussion, yes this is a good feature for googletest to consider. |
I will look into it. What is your take on problems mentioned earlier?
|
@aprelev
Could you please clarify why you feel that this may not be a good idea? I don't immediately see issues with it
Skipping preceding failure seems to be logical. Skip is a user over-ride, meaning "I know better that this test can not run so lets skip it". Moreover, deciding to skip the test should be done in the very beginning of the test.
Dont see a need to complicate this way. Skipping a test is a user-override for this test. It should be decided on the test level and not outside it Dont forget the docs! Thank you again |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
Okay, I've looked into implementing skipping with function. As far as I understand, fatal failure, #define SKIP() \
return AssertHelper() = Message()
^^^^^^
TestBody() {
SKIP();
FAIL(); // < This will not be executed.
} Any function, on the other hand, fails to escape current scope, unless exception is thrown or long jump is performed, therefore rendering skipping useless. TestBody() {
::testing::SkipTest();
FAIL(); // < This will be executed anyway.
} Could you be more specific on how test skipping could be implemented with function; and what was the rationale behind your decision? |
@gennadiycivil Okay, no worries :) poke me here once you are done with important stuff |
Any update here?
|
I am waiting for @gennadiycivil for his attention on this feature and implementation mechanics. |
I don't know if this needs to be in this PR, but it'd be useful to me if we could skip all tests from a test fixture. Something like: class MyTestFixture : public ::testing::Test {
protected:
virtual void SetUp() override {
if (runtime_check_failed) {
SkipAll(); // defined in base class
return;
}
} |
@aprelev please resolve all conflicts. Thank you |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) |
CLAs look good, thanks! |
Ping. |
@aprelev I made the changes in your branch. Please add documentation and ping me when ready |
Okay, sure thing. |
@aprelev Thanks! Your PR really helps a lot. Hope it can be merged soon =) |
This PR is ready to be merged. I am waiting for the docs @aprelev @zrphercule |
PiperOrigin-RevId: 215273083
PiperOrigin-RevId: 215273083
@aprelev given that others are waiting, |
@aprelev Ping on documentation? |
Hi guys, GTEST_SKIP() is available from which release onwards. I need it for my unit testing. Not finding sufficient details on this, so posting here |
@sandy5842 given that the last tagged release (1.8.1 at time of writing) dates back to the end of August 2018, I'd say it is still yet unreleased unfortunately. |
It is in the master branch and has been for a while . |
- Update to the version that adds GTEST_SKIP macro to google test - google#1544
Hi Guys, does this also put |
A subsection "Skipping test execution" was added to document GTEST_SKIP and where it can be used. relates issue google#1544
A subsection "Skipping test execution" was added to document GTEST_SKIP and where it can be used. relates issue google#1544
A subsection "Skipping test execution" was added to document GTEST_SKIP and where it can be used. relates issue google#1544
Description
Nothing fancy, plain and simple test skipping based on condition evaluated at runtime. One might want to skip
Feature has been requested several times, see #160, #490 and #822. Works as demonstrated in sample test:
yields
Skipped tests are displayed in green, and are not considered neither successful nor failed since they have never been completely run.
Further work
There are some conceptual issues which are not yet resolved, but I would love to hear you thoughts on them.
kSkip
result.SetUp()
andTearDown()
methods, as well as from functions external to test body, since skipping aborts only current function; this can be resolved by adding additionalAssertHelpers
in fashion similar to handlingFAIL()
.