Tag: ocunit

OCUnittesting现有的iOS项目。 “ld:找不到文件”

我一直在关注这个博客文章: 添加unit testing到现有的项目。 但是我得到这个错误: ld:找不到文件:Build / Products / Debug-iphoneos / MyApp.app / MyApp Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang失败,退出代码为1 我有我的testing目标属性, Bundle Loader = $(BUILT_PRODUCTS_DIR)/MyApp.app/MyApp testing主机= $(BUNDLE_LOADER) (这两个等同于:构build/ Debug-iphoneos / MyApp.app / MyApp) 我疯狂的猜测是,这些variables不是指向编译器相同的位置。 “build / Debug-iphoneos / …”vs“Build / Products / Debug-iphoneos / …” 我可能完全错误的猜测,但无论哪种方式,有没有人知道是什么原因导致这个错误,或者我将如何修复这些环境variables? 谢谢你的帮助, 山姆

Xcode 4unit testing链接器错误

注意:“使用GHUnit”不是这个问题可接受的答案。 我知道大多数人认为GHUnit比Xcode4 OCUnit好,但这不是我所问的。 我会分开评估。 我有一个从头开始在Xcode4中创build的Xcode项目,在创build期间选中“包括unit testing”checkbox。 我还包括了一些在以前的项目中开发的库。 他们通过“Add Files to x …”对话框添加到项目中,只添加到应用程序目标(而不是testing目标)。 运行应用程序时它们工作正常,所以我认为它们设置正确。 我也为这个项目编写了许多不同的类。 我的testing文件是以标准方式设置的,名为[AppName] Tests.h和.m。 代码为标题: #import < SenTestingKit/SenTestingKit.h > @interface [AppName]Tests : SenTestCase { @private } @end 实施守则: #import "[AppName]Tests.h" @implementation [AppName]Tests – (void)setUp { [super setUp]; // Set-up code here. } – (void)tearDown { // Tear-down code here. [super tearDown]; } // […]

OCUnittesting用例没有运行

如果我创build一个包含unit testing的新项目,testing用例会被调用。 但是当我添加testing到一个现有的项目,我在日志中得到以下内容: 2013-05-21 19:41:08.814 otest[51593:7e03] Unknown Device Type. Using UIUserInterfaceIdiomPhone based on screen size Test Suite '/Users/impadmin/Library/Developer/Xcode/DerivedData/SmartDiary-frrybdtgyyjgewbialqsmxkwvlxs/Build/Products/Debug-iphonesimulator/testSmartDiary.octest(Tests)' 开始于2013-05-21 14:11:09 +0000testing套件'testShowContacts'开始于2013-05-21 14:11:09 +0000testing套件'testShowContacts'于2013-05-21 14:11:09结束+0000。 执行0次testing,在0.000(0.000)秒内发生0次失败(0次意外) 我已经将SenTestKit添加到框架,然后通过添加目标添加testing捆绑。 我哪里错了? 让我在这里添加方法和testing用例: //要testing的方法 -(IBAction)addTask{ if(!([mPriority.text isEqualToString:@"1"] ||[mPriority.text isEqualToString:@"2"] ||[mPriority.text isEqualToString:@"3"] ||[mPriority.text isEqualToString:@"4"] ||[mPriority.text isEqualToString:@"5"])) { NSLog(@"Enter valid Priority value"); } else if ([mTaskName.text isEqualToString:@""]) { NSLog(@"Task name can't be […]

超时等待120秒模拟器启动

它看起来像Teamcity代理(TC版本是9.0 EAP)不能通过testingshell脚本运行iOS Simulator 。 我正在使用Build Step: Command Line ,运行Custom Script并传递参数。 在Mac OS X Yosemite 10.10上使用shell脚本../bin/mac.launchd.sh启动Teamcity代理。 生成日志错误: [12:33:24][Step 2/2] 2014-11-20 11:33:25.421 xcodebuild[28083:289783] iPhoneSimulator: Timed out waiting 120 seconds for simulator to boot, current state is 1. [12:33:24][Step 2/2] [12:33:24][Step 2/2] Testing failed: [12:33:24][Step 2/2] Test target app-tests encountered an error (Timed out waiting 120 seconds for […]

iOSunit testing:如何设置/更新/检查firstResponder?

你如何编写第一响应unit testing? 我试图写一个testing来确认一个方法将焦点推进到下一个文本字段。 controller是UIViewController的后代。 但是这个探索性testing失败了: – (void)testFirstResponder { [controller view]; [[controller firstTextField] becomeFirstResponder]; STAssertTrue([[controller firstTextField] isFirstResponder], nil); } 第一行导致视图被加载,以便其网点到位。 文本字段是非零。 但testing永远不会通过。 我猜想, becomeFirstResponder不会立即设置第一响应者,但安排它以后。 那么是否有一个很好的方法来写一个unit testing呢? 从已接受的答案中的评论中拉出答案让事情运行一小段时间: [[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]];

如何运行和debuggingiPhone应用程序的unit testing

注:unit testing现在更容易设置。 本教程与Xcode版本5及以上版本无关。 我花了相当一段时间,但终于成功地为我的项目工作。 为了创build“逻辑”testing,我遵循了关于创build逻辑testing的Apple指导原则 。 一旦你明白逻辑testing是在构build过程中运行的,这个工作正常。 为了能够debugging这些testing,需要创build一个自定义可执行文件来调用这些testing。 Sean Miceli在Grokking Cocoa博客上的文章提供了所有这些信息。 然而,之后并没有立竿见影的成功,需要一些调整。 我将详细介绍Sean教程中的主要步骤,提供一些“傻瓜”轮廓,这些轮廓花了我一些时间来弄清楚: 设置一个包含unit testing但不运行它们的目标 安装可执行文件以运行testing 设置最简单的环境variables,以便可以find你的unit testing 以下是使用XCode 3.2.5进行的 注意XCode 4 在XCode 4中,可以直接debugging你的unit testing。 只需编写testing,将其作为testing之一添加到目标中,并在其中设置断点。 就这样。 更多将会来。 步骤1 – 设置目标 复制您的项目目标下的unit testing目标。 这也将创buildunit testing产品(.octest文件)的副本。 在下图中,“LogicTest”是原始目标。 将unit testing目标和unit testing产品(.octest文件)重命名为相同的名称。 在下图中“LogicTestsDebug”是重复的目标。 删除新目标的RunScript阶段 两者的名称可以是任何东西,但我会避免空格。 第2步 – 设置otest 这里最重要的一点是要得到正确的,也就是说你的iOS版本,而不是默认的Mac版本。 这在肖恩的教程中有很好的描述。 以下是一些帮助我设置正确的更多细节: 转到项目 – >新的自定义可执行文件。 这将popup一个窗口,提示您input一个可执行文件名称和一个可执行文件path。 input任何你想要的名字。 复制粘贴path到您的iOS otest可执行文件。 […]

当ViewController从UIStoryboard实例化时,isMemberOfClass返回no

我有一个OCUnittesting类:PatientTestViewControllerTests。 以下是界面: @interface PatientTestViewControllerTests : SenTestCase @property (nonatomic, strong) PatientTestViewController *testController; @end 和setUp: – (void) setUp { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Testing" bundle:nil]; self.testController = [storyboard instantiateInitialViewController]; } “testing”故事板是我应用程序中唯一的故事板,并被设置为应用程序的主要故事板。 PatientTestViewController被设置为故事板唯一的视图控制器。 我在testing课上有一个testing: – (void) testInitialTestingStoryboardViewIsPatientTest { STAssertTrue([self.testController isMemberOfClass:[PatientTestViewController class]], @"Instead of the %@, we have %@",[PatientTestViewController class], [self.testController class]); } 此testing失败并显示以下日志消息: 错误: – [PatientTestViewControllerTests testInitialTestingStoryboardViewIsPatientTest]:“[self.testController isMemberOfClass:[PatientTestViewController […]