Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 针对安装和拆卸OCUnit测试用例引发异常 -(无效)设置 { [超级设置]; @试一试{ [问题]; } @捕获(NSException*异常){ NSLog(@“异常捕获%@:%@,[异常名称],[异常原因]); STFail(@“应通过,不应出现异常。异常”,异常); } } -(无效)拆卸 { //在这里删除代码。 @试一试{ [问题撕裂问题]; } @捕获(NSException*异常){ NSLog(@“异常捕获%@:%@,[异常名称],[异常原因]); STFail(@“应通过,不应出现异常。异常”,异常); } } -(void)testGetComponentNil{ id testComponet=(id)[问题getComponent:nil]; statsertnil(testComponet,@“Return Nil”); statsertnotnil(id[problem getComponent:@“problem”],@“”); } 在InternalInconsistenceException:无法在setupProblem()之前删除DownProblem()_Iphone_Ocunit - Fatal编程技术网

Iphone 针对安装和拆卸OCUnit测试用例引发异常 -(无效)设置 { [超级设置]; @试一试{ [问题]; } @捕获(NSException*异常){ NSLog(@“异常捕获%@:%@,[异常名称],[异常原因]); STFail(@“应通过,不应出现异常。异常”,异常); } } -(无效)拆卸 { //在这里删除代码。 @试一试{ [问题撕裂问题]; } @捕获(NSException*异常){ NSLog(@“异常捕获%@:%@,[异常名称],[异常原因]); STFail(@“应通过,不应出现异常。异常”,异常); } } -(void)testGetComponentNil{ id testComponet=(id)[问题getComponent:nil]; statsertnil(testComponet,@“Return Nil”); statsertnotnil(id[problem getComponent:@“problem”],@“”); } 在InternalInconsistenceException:无法在setupProblem()之前删除DownProblem()

Iphone 针对安装和拆卸OCUnit测试用例引发异常 -(无效)设置 { [超级设置]; @试一试{ [问题]; } @捕获(NSException*异常){ NSLog(@“异常捕获%@:%@,[异常名称],[异常原因]); STFail(@“应通过,不应出现异常。异常”,异常); } } -(无效)拆卸 { //在这里删除代码。 @试一试{ [问题撕裂问题]; } @捕获(NSException*异常){ NSLog(@“异常捕获%@:%@,[异常名称],[异常原因]); STFail(@“应通过,不应出现异常。异常”,异常); } } -(void)testGetComponentNil{ id testComponet=(id)[问题getComponent:nil]; statsertnil(testComponet,@“Return Nil”); statsertnotnil(id[problem getComponent:@“problem”],@“”); } 在InternalInconsistenceException:无法在setupProblem()之前删除DownProblem(),iphone,ocunit,Iphone,Ocunit,首先调用setup方法并调用testcaseMethod,然后调用detall-down。安装前将其拆下, 有人就这个问题向我提出建议,为什么要在安装之前拆卸它。不要在安装或拆卸中放置STFail断言。您也不需要异常处理;OCUnit将捕获并报告抛出的任何异常。您可以打印调用堆栈,并使用SenTestCaseDidFailNotification查看这些异常: 例如: - (void)setUp { [super setUp]; @try { [Problem s

首先调用setup方法并调用testcaseMethod,然后调用detall-down。安装前将其拆下,
有人就这个问题向我提出建议,为什么要在安装之前拆卸它。

不要在安装或拆卸中放置STFail断言。您也不需要异常处理;OCUnit将捕获并报告抛出的任何异常。

您可以打印调用堆栈,并使用
SenTestCaseDidFailNotification查看这些异常:

例如:

- (void)setUp
{
    [super setUp];
    @try {
        [Problem setupProblem];
    }
    @catch (NSException *exception) {

        NSLog(@"exception Caught %@: %@", [exception name], [exception reason]);
        STFail(@"Should Pass, no exception is expected. Exception <%@>", exception);
    }
}

- (void)tearDown
{
    // Tear-down code here.

    @try {
        [Problem teardownproblem];
    }
    @catch (NSException* exception) {

        NSLog(@"exception Caught %@: %@", [exception name], [exception reason]);
    STFail(@"Should Pass, no exception is expected. Exception <%@>", exception);
}
    }
-(void)testGetComponentNil{

    id testComponet = (id<Solution>)[Problem getComponent:nil];
            STAssertNil(testComponet, @"Return Nil");
STAssertNotNil(id<Solution>[problem getComponent:@"Problem"], @"");

}


exception Caught NSInternalInconsistencyException: Cannot teardownProblem() before setupProblem()

 <Cannot teardownProblem() before setupProblem().>

对于我的安装和拆卸,不应引发异常!我不知道那个[问题];已成功完成拆卸[问题拆卸问题];如果这个方法没有正确设置,它会给我错误值,不需要抛出异常!
@implementation TestCase
- (void)setUp
{
    [super setUp];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFailTest:) name:SenTestCaseDidFailNotification object:nil];
}

- (void)didFailTest:(NSNotification *)notification
{
    SenTestCaseRun *theRun = notification.object;

    for (NSException *exception in theRun.exceptions) {
        NSLog(@"Exception: %@ - %@", exception.name, exception.reason);
        NSLog(@"\n\nCALL STACK: %@\n\n",exception.callStackSymbols);
    }
} 
@end