XCode?μ?iOS???????
???????????? ???????[ 2014/1/8 15:35:40 ] ??????????????? iOS ???????
??????е? All ??????????????Failed ??????????????????????GHUnit????????? GHUnitSampleTest ????μ????????磺
- (void)testSimpleFail
{
GHAssertTrue(NO?? nil);
}
????????????? Tests ??????????????????????? GHTestCase???????е????????????????????????????????? test ??????ɡ?
????OCMock
????????????????? OCMock??
????1??????????????????????? OCMock???? GHUnitTest ??????? Libraries ???????????? Tests ?????????????????????????????????????
???????????????? libOCMock.a ??framework ?????OCMock framework ?????????? ocmock-1.77.dmg?????????е?‘Release/Library/Headers/OCMock’ ???? Libraries ????????????£?
????2???? GHUnitTest ???????????? Libraries ?? group??????libOCMock.a ???? OCMock????? target ?? Tests??
????3?????? Tests ?? Build Setting???? Libray Search Paths ???? $(SRCROOT)/Libraries??
?????? Header Search Paths ?????? $(SRCROOT)/Libraries??????? Recursive ????
????4????д OCMock ??????? Tests ???????????? OCMockSampleTest ?? Objective C class???????????£?
OCMockSampleTest.h
#import <GHUnitIOS/GHUnit.h>
@interface OCMockSampleTest : GHTestCase
@end
OCMockSampleTest.m
#import "OCMockSampleTest.h"
#import <OCMock/OCMock.h>
@implementation OCMockSampleTest
// simple test to ensure building?? linking??
// and running test case works in the project
- (void)testOCMockPass
{
id mock = [OCMockObject mockForClass:NSString.class];
[[[mock stub] andReturn:@"mocktest"] lowercaseString];
NSString *returnValue = [mock lowercaseString];
GHAssertEqualObjects(@"mocktest"?? returnValue??
@"Should have returned the expected string.");
}
- (void)testOCMockFail
{
id mock = [OCMockObject mockForClass:NSString.class];
[[[mock stub] andReturn:@"mocktest"] lowercaseString];
NSString *returnValue = [mock lowercaseString];
GHAssertEqualObjects(@"thisIsTheWrongValueToCheck"??
returnValue?? @"Should have returned the expected string.");
}
@end
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11