سؤال

I have a seemingly weird problem (unless I'm missing something totally obvious!) and am curious if anyone here has any insight. I've done quite a bit of searching and haven't found anything.

When I try and write unit tests in XCTest - creating new methods - they don't seem to register as tests and aren't executed when I run the test suite. They also don't get one of those nice little diamond run buttons next to them that allows you to run individual tests: enter image description here

When using JUnit for example here you would annotate with @Test. Anything like this I'm missing?

هل كانت مفيدة؟

المحلول

Only method names that start with test are being recognized as tests. That way you can still use normal methods in your test classes that your actual test methods can call.

نصائح أخرى

Restart Xcode

New methods starting with test... were not being tested in my Test target.

- (void)testMethod {
    // not tested
}

Solution was to restart Xcode.

Your new method must begin with "test", after add it , cmd + B, you will find your new method on your test navigator.

I had disabled indexing like this:

defaults write com.apple.dt.Xcode IDEIndexDisable -bool true

setting it back to false and Xcode restart fixed it.

Make sure the test class in part of your test target.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top