[英]not getting the values in xctest
我已經將稱為按鈕狀態的方法聲明為-(int)buttonstate;
在xctest.m
當我實例化我的viewController並分配給一個int值時,我得到了錯誤的值。
-(int) buttonstate {
if ([searchButton isEnabled]) {
j = 1;
}
else
j = 0;
NSLog(@" j value is %d",j);
return j;
}
並在xctest .m文件中
-(void) testwithoutData {
myapiViewController *apiViw = [[myapiViewController alloc]init];
int kn = [apiViw buttonstate];
NSLog(@"the value is %ld",(long)kn);
}
這是我嘗試過的-
在ViewController.h中
@interface ViewController : UIViewController{
@public int index;
}
在ViewController.m中
-(void) drawCircle{
index = 10;
NSLog(@"the value is %ld",(long)index);
}
在ViewControllerTests.m中
@interface ViewControllerTests : XCTestCase
@property (nonatomic,strong) ViewController *vcToTest;
@end
@implementation ViewControllerTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
self.vcToTest = [[ViewController alloc] init];
}
- (void)testExample {
// This is an example of a functional test case.
XCTAssert(YES, @"Pass");
[self.vcToTest drawCircle];
NSLog(@"Test is fine. Value %d",self.vcToTest->index);
}
測試結果 -
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.