rules_apple icon indicating copy to clipboard operation
rules_apple copied to clipboard

How to disable tests in ios_unit_test?

Open Tony1023 opened this issue 4 years ago • 12 comments

In Xcode, we can disable tests in the file inspector. Those are recorded in xcscheme. Is there a way to do so with ios_unit_test?

Tony1023 avatar Aug 02 '19 23:08 Tony1023

This isn't currently supported. We normally prefix the test name with disabled_

keith avatar Aug 03 '19 00:08 keith

@keith Thanks, but will this be supported at some point?

Tony1023 avatar Aug 03 '19 00:08 Tony1023

I haven't heard any plans, but someone from Google would have to answer that one.

keith avatar Aug 03 '19 00:08 keith

@keith Thanks for the info! :)

Tony1023 avatar Aug 03 '19 00:08 Tony1023

IMO you can keep this issue open until there's input from someone from Google, since this might be a reasonable feature request

keith avatar Aug 03 '19 01:08 keith

@keith Yeah you're right. Will post in Bazel's Google groups too. If there are any updates from them I will update this issue too.

Tony1023 avatar Aug 03 '19 01:08 Tony1023

Are you looking to disable the whole test or just a test method?

In stock Xcode you don't really "disable" a test, as much as schemes control what tests/test methods the scheme invokes, if you create a new scheme, all of the tests are still fair game as nothing marks them as disabled in the code.

thomasvl avatar Aug 05 '19 14:08 thomasvl

The closest thing to this is Bazel's --test_filter command line flag, but I believe it would be the responsibility of each test runner implementation to honor that setting and pass it through the underlying xctest command.

allevato avatar Aug 05 '19 14:08 allevato

Are you looking to disable the whole test or just a test method?

@thomasvl A whole test, but the test class is inherited by others which use the same test methods w/ different setup's. We have not found a way to exclude the methods in the base class yet.

In stock Xcode you don't really "disable" a test, as much as schemes control what tests/test methods the scheme invokes, if you create a new scheme, all of the tests are still fair game as nothing marks them as disabled in the code.

Yes. So is there an easy way to feed the xcscheme file to ios_unit_test?

Tony1023 avatar Aug 05 '19 20:08 Tony1023

not really, we don't support xcschemes for running nor testing.

sergiocampama avatar Aug 21 '19 15:08 sergiocampama

Do I understand it correctly that test_filter is a no-op for XCTest? (If so, maybe this should be documented?).

I am looking to replicate this default Xcode feature:

image

... image

So disabling entire files containing tests.

You can right click a test (suite) to disable it, not sure what this does:

image

louwers avatar Jul 03 '23 11:07 louwers

--test_filter is supported as of the more recent releases. But that's really more useful for a single one off test run where you want to disable a test, not disabling permanently like that in Xcode. AFAIUI that option in Xcode commits to your xctestrun file that a single test is disabled.

keith avatar Jul 05 '23 17:07 keith