问题
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:
When using JUnit for example here you would annotate with @Test. Anything like this I'm missing?
回答1:
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.
回答2:
New methods with test... were not being tested in my Test target.
- (void)testMethod {
// not tested
}
Solution was to Restart Xcode
回答3:
Your new method must begin with "test", after add it , cmd + B, you will find your new method on your test navigator.
来源:https://stackoverflow.com/questions/22131579/xctest-not-registering-new-methods-as-tests