XCTest not registering new methods as tests

此生再无相见时 提交于 2019-12-08 15:48:57

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!