OCUnit测试用例未运行

编程入门 行业动态 更新时间:2024-10-28 17:27:11
本文介绍了OCUnit测试用例未运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果我创建一个包含单元测试的新项目,则会调用测试用例.但是,当我将测试添加到现有项目时,我在日志中得到以下内容:

If I create a new project which includes unit tests, the test cases get called. But when I'm adding tests to an existing project I'm getting the following in the log:

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 +0000 测试套件"testShowContacts"始于2013-05-21 14:11:09 +0000 测试套件'testShowContacts'于2013-05-21 14:11:09 +0000完成. 已执行0次测试,在0.000(0.000)秒内发生0次失败(0次意外)

started at 2013-05-21 14:11:09 +0000 Test Suite 'testShowContacts' started at 2013-05-21 14:11:09 +0000 Test Suite 'testShowContacts' finished at 2013-05-21 14:11:09 +0000. Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds

我已经将SenTestKit添加到框架中,然后通过添加目标"添加了测试包. 我要去哪里错了?

I've added the SenTestKit to the frameworks, and then added the testing bundle via Add Target. Where am I going wrong?

让我在此处添加方法及其测试用例:

Let me add the method and its test case here:

//要测试的方法

-(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 blank"); } else{ sqlite3_stmt *statement; const char *dbPath = [mDatabasePath UTF8String]; //[[appViewController returnObject].mDatabasePath UTF8String]; if (sqlite3_open(dbPath, &mDiary) == SQLITE_OK) { NSLog(@"%@",mPriority.text); NSString *insertSQL2=[NSString stringWithFormat:@"INSERT INTO TODO VALUES(\"%@\",\"%@\",\"%@\",\"%@\",\"%@\")",mStartDate.text,mEndDate.text,mTaskName.text,mTaskDescription.text,mPriority.text]; NSLog(@"%@",insertSQL2); const char *insert_stmt2 = [insertSQL2 UTF8String]; sqlite3_prepare_v2(mDiary, insert_stmt2, -1, &statement, NULL); NSLog(@"%@",mPriority.text); if (sqlite3_step(statement) == SQLITE_DONE ) { mStartDate.text=@""; mEndDate.text=@""; mTaskName.text=@""; mTaskDescription.text=@""; mPriority.text=@""; } else { NSLog(@"failed to add"); } sqlite3_finalize(statement); sqlite3_close(mDiary); } } }

//这是测试:

-(void)testAddTask { AddTaskViewController *obj; obj = [[AddTaskViewController alloc]init]; obj.mTaskName.text = @"t1"; obj.mTaskDescription.text = @"t2"; obj.mStartDate.text = @"56987"; obj.mEndDate.text = @"55425"; obj.mPriority.text = @"3"; [obj addTask]; sqlite3_stmt *statement; const char *dbpath = [obj.mDatabasePath UTF8String]; if (sqlite3_open(dbpath,&mDiaryTest)== SQLITE_OK) { NSString *selectSQL = [NSString stringWithFormat:@"SELECT * FROM TODO WHERE mTaskName = \"%@\"",obj.mTaskName.text]; const char *query_stmt = [selectSQL UTF8String]; if (sqlite3_prepare_v2(mDiaryTest, query_stmt, -1, &statement, NULL) == SQLITE_OK) { if(sqlite3_step(statement) == SQLITE_ROW) { testString = [[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(statement, 1)]; } } } sqlite3_finalize(statement); sqlite3_close(mDiaryTest); NSLog(@"%@",testString); STAssertEquals(testString,@"t2",@"should be equal"); }

我发现在目标依赖项中,该项​​目未被选中.我检查并再次测试,随后出现以下错误:

I found that in target dependencies the project was unchecked. I checked it and tested again, whereupon I'm getting the following errors:

Undefined symbols for architecture i386: "_OBJC_CLASS_$_AddTaskViewController", referenced from: objc-class-ref in testAddTask.o "_sqlite3_close", referenced from: -[testAddTask testAddTask] in testAddTask.o "_sqlite3_column_text", referenced from: -[testAddTask testAddTask] in testAddTask.o "_sqlite3_finalize", referenced from: -[testAddTask testAddTask] in testAddTask.o "_sqlite3_open", referenced from: -[testAddTask testAddTask] in testAddTask.o "_sqlite3_prepare_v2", referenced from: -[testAddTask testAddTask] in testAddTask.o "_sqlite3_step", referenced from: -[testAddTask testAddTask] in testAddTask.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

由于最初的问题完全不同,所以我知道这可能是个话题,但是有人可以告诉我为什么会出现这些错误吗?我已经添加了必要的框架.

I know this is probably going off topic, since the original question was entirely different, but can anyone please tell me why these errors are coming? I've added the necessary frameworks.

推荐答案

在测试UIKit依赖项时,您要运行应用程序测试.确保已设置Bundle Loader和Test Host构建设置(请参阅文档).

As you are testing UIKit dependent stuff, you want to run Application Tests. Make sure you have set the Bundle Loader and Test Host build settings (refer to the documentation).

此外,还必须将libsqlite3.0.dylib与测试目标链接,因为在单元测试中使用的是sqlite函数.

Further you have to link the libsqlite3.0.dylib against your tests target too, because you are using sqlite functions in your unit tests.

更多推荐

OCUnit测试用例未运行

本文发布于:2023-05-25 12:57:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/228594.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:词库加载错误:Could not find file 'D:\淘小白 高铁采集器win10\Configuration\Dict_Sto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!