OCUnit tests not running / not being found

心已入冬 提交于 2019-12-11 06:34:59

问题


I'm trying to get to grips with OCTest, but can't seem to get it to actually run my tests (at least, I believe it's not running my tests). I've set up a project as described in the developer documentation, and added a class called UnitTests which contains the following function:

-(void)testFailures
{
    STFail(@"A message");
}

When I build the test bundle (in Debug or Release), the Build Results panel shows briefly that it's running the unit tests (it says something like 'Running unit tests for ... (GC OFF)'), but then shows the Build Succeeded message. The same occurs when I put less trivial tests in, such as:

- (void)testFramework
{
    NSString *string1 = @"test";
    NSString *string2 = @"testing";
    STAssertEquals(string1,
               string2,
               @"FAILURE");
}

Any ideas as to where I'm going wrong?


回答1:


  1. Setting the target for the project to ocunit?
  2. In the info for your m file, is it targeting OCUnit?



回答2:


I grappled with similar issues today. First, look at the iOS-specific unit test documentation. Then, ensure that you did not stumble over something silly like not importing

#import <SenTestingKit/SenTestingKit.h>

Then, there's an issue with XCode that causes an error with OCUnit/SenTest, but this is how to resolve it.




回答3:


Here is an Updated Link to the Apple Docs on unit testing.



来源:https://stackoverflow.com/questions/3608484/ocunit-tests-not-running-not-being-found

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