Commit 7a670dd0 authored by jz's avatar jz

添加单元测试

parent 4707c483
......@@ -8,9 +8,11 @@
/* Begin PBXBuildFile section */
04220B4324E14A7A00C4E21B /* GMTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04220B4224E14A7A00C4E21B /* GMTableViewController.m */; };
04220B4624E14DF700C4E21B /* Target_Common.m in Sources */ = {isa = PBXBuildFile; fileRef = 04220B4524E14DF700C4E21B /* Target_Common.m */; };
04220B4924E14EC200C4E21B /* GMRouterTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 04220B4824E14EC200C4E21B /* GMRouterTool.m */; };
04220B4C24E150E800C4E21B /* GMNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04220B4B24E150E800C4E21B /* GMNavigationController.m */; };
04BB24C824E5410800CC4CB6 /* Target_GMRouterCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 04BB24C724E5410800CC4CB6 /* Target_GMRouterCase.m */; };
04BB24CB24E5414200CC4CB6 /* Target_CommonCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 04BB24C924E5414200CC4CB6 /* Target_CommonCase.m */; };
04BB24CE24E5422100CC4CB6 /* Target_common.m in Sources */ = {isa = PBXBuildFile; fileRef = 04BB24CD24E5422100CC4CB6 /* Target_common.m */; };
6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; };
6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
......@@ -43,12 +45,15 @@
/* Begin PBXFileReference section */
04220B4124E14A7A00C4E21B /* GMTableViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GMTableViewController.h; sourceTree = "<group>"; };
04220B4224E14A7A00C4E21B /* GMTableViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GMTableViewController.m; sourceTree = "<group>"; };
04220B4424E14DF700C4E21B /* Target_Common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Target_Common.h; sourceTree = "<group>"; };
04220B4524E14DF700C4E21B /* Target_Common.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Target_Common.m; sourceTree = "<group>"; };
04220B4724E14EC200C4E21B /* GMRouterTool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GMRouterTool.h; sourceTree = "<group>"; };
04220B4824E14EC200C4E21B /* GMRouterTool.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GMRouterTool.m; sourceTree = "<group>"; };
04220B4A24E150E800C4E21B /* GMNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GMNavigationController.h; sourceTree = "<group>"; };
04220B4B24E150E800C4E21B /* GMNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GMNavigationController.m; sourceTree = "<group>"; };
04BB24C724E5410800CC4CB6 /* Target_GMRouterCase.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Target_GMRouterCase.m; sourceTree = "<group>"; };
04BB24C924E5414200CC4CB6 /* Target_CommonCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Target_CommonCase.m; sourceTree = "<group>"; };
04BB24CA24E5414200CC4CB6 /* Target_CommonCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Target_CommonCase.h; sourceTree = "<group>"; };
04BB24CC24E5422100CC4CB6 /* Target_common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Target_common.h; sourceTree = "<group>"; };
04BB24CD24E5422100CC4CB6 /* Target_common.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Target_common.m; sourceTree = "<group>"; };
1023953C32A7010DB53FBBC4 /* Pods-GMRouter_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GMRouter_Tests.release.xcconfig"; path = "Target Support Files/Pods-GMRouter_Tests/Pods-GMRouter_Tests.release.xcconfig"; sourceTree = "<group>"; };
2D703B8D4908D47D2426A0FC /* Pods_GMRouter_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GMRouter_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4191355538D66BC19D7E9984 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
......@@ -155,8 +160,8 @@
04220B4824E14EC200C4E21B /* GMRouterTool.m */,
04220B4124E14A7A00C4E21B /* GMTableViewController.h */,
04220B4224E14A7A00C4E21B /* GMTableViewController.m */,
04220B4424E14DF700C4E21B /* Target_Common.h */,
04220B4524E14DF700C4E21B /* Target_Common.m */,
04BB24CC24E5422100CC4CB6 /* Target_common.h */,
04BB24CD24E5422100CC4CB6 /* Target_common.m */,
71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */,
6003F5A8195388D20070C39A /* Images.xcassets */,
6003F594195388D20070C39A /* Supporting Files */,
......@@ -180,6 +185,9 @@
isa = PBXGroup;
children = (
6003F5BB195388D20070C39A /* Tests.m */,
04BB24CA24E5414200CC4CB6 /* Target_CommonCase.h */,
04BB24C924E5414200CC4CB6 /* Target_CommonCase.m */,
04BB24C724E5410800CC4CB6 /* Target_GMRouterCase.m */,
6003F5B6195388D20070C39A /* Supporting Files */,
);
path = Tests;
......@@ -395,9 +403,10 @@
buildActionMask = 2147483647;
files = (
6003F59E195388D20070C39A /* GMAppDelegate.m in Sources */,
04BB24CE24E5422100CC4CB6 /* Target_common.m in Sources */,
04BB24CB24E5414200CC4CB6 /* Target_CommonCase.m in Sources */,
04220B4324E14A7A00C4E21B /* GMTableViewController.m in Sources */,
6003F5A7195388D20070C39A /* GMViewController.m in Sources */,
04220B4624E14DF700C4E21B /* Target_Common.m in Sources */,
04220B4C24E150E800C4E21B /* GMNavigationController.m in Sources */,
04220B4924E14EC200C4E21B /* GMRouterTool.m in Sources */,
6003F59A195388D20070C39A /* main.m in Sources */,
......@@ -408,6 +417,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
04BB24C824E5410800CC4CB6 /* Target_GMRouterCase.m in Sources */,
6003F5BC195388D20070C39A /* Tests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......
//
// Target_common.h
// GMRouter_Example
//
// Created by Q14 on 2020/8/13.
// Copyright © 2020 Q14. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface Target_common : NSObject
@end
NS_ASSUME_NONNULL_END
//
// Target_common.m
// GMRouter_Example
//
// Created by Q14 on 2020/8/13.
// Copyright © 2020 Q14. All rights reserved.
//
#import "Target_common.h"
#import "GMViewController.h"
#import "GMRouterTool.h"
#import <UIKit/UIKit.h>
@implementation Target_common
- (UIViewController *)common:(NSDictionary *)params {
GMViewController *vc = [[GMViewController alloc] init];
NSLog(@"params====%@======", params);
[[GMRouterTool getCurrentViewController].navigationController pushViewController:vc animated:YES];
return vc;
}
@end
......@@ -9,6 +9,8 @@ source 'git@git.wanmeizhensuo.com:gengmeiios/GMSpecs.git'
target 'GMRouter_Example' do
pod 'GMRouter', :path => '../'
# pod 'GMRouter', '~> 0.1', :testspecs => ['Tests']
target 'GMRouter_Tests' do
inherit! :search_paths
......
......@@ -5,7 +5,7 @@ PODS:
- GMCache
- MagicalRecord
- MJExtension
- GMRouter (0.2.7):
- GMRouter (0.2.8):
- GMPhobos
- MJExtension
- MagicalRecord (2.3.2):
......@@ -33,11 +33,11 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
GMCache: b78d8e46db864405e91d226ce640cc80d966c611
GMPhobos: 981b9c9509945eaa28b4ad6a5376eb78f3fd54b5
GMRouter: a7b6be83b3d946837929ecc50fd09c4b9342f952
GMRouter: 0959e43e34e65ae098452c4d62d63f90b206b274
MagicalRecord: 53bed74b4323b930992a725be713e53b37d19755
MJExtension: 635f2c663dcb1bf76fa4b715b2570a5710aec545
TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed
PODFILE CHECKSUM: ea22114f5446c23313cc25de2cf84ff760e403e0
PODFILE CHECKSUM: 9abfb1378000321a0e369a24986281ef5c26f6b5
COCOAPODS: 1.9.3
......@@ -10,7 +10,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface Target_Common : NSObject
@interface Target_CommonCase : NSObject
@end
......
......@@ -6,13 +6,14 @@
// Copyright © 2020 Q14. All rights reserved.
//
#import "Target_Common.h"
#import "Target_CommonCase.h"
#import "GMViewController.h"
#import "GMRouterTool.h"
@implementation Target_Common
@implementation Target_CommonCase
- (UIViewController *)common:(NSDictionary *)params {
GMViewController *vc = [[GMViewController alloc] init];
NSLog(@"params====%@======", params);
[[GMRouterTool getCurrentViewController].navigationController pushViewController:vc animated:YES];
return vc;
......
//
// GMRouterCase.m
// GMRouter_Tests
//
// Created by Q14 on 2020/8/13.
// Copyright © 2020 Q14. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "GMViewController.h"
#import <GMRouter/GMRouter.h>
#import <GMRouter/GMRouter+gm.h>
#import "GMRouterTool.h"
@interface Target_GMRouterCase : XCTestCase
@end
@implementation Target_GMRouterCase
- (UIViewController *)common_params:(NSDictionary *)params {
GMViewController *vc = [[GMViewController alloc] init];
XCTAssertTrue(params.allKeys.count != 0, @"common_params 参数解析失败");
[[GMRouterTool getCurrentViewController].navigationController pushViewController:vc animated:YES];
return vc;
}
- (UIViewController *)common_no_params:(NSDictionary *)params {
GMViewController *vc = [[GMViewController alloc] init];
XCTAssertTrue(params.allKeys.count == 0, @"common_no_params 应该不会有参数");
[[GMRouterTool getCurrentViewController].navigationController pushViewController:vc animated:YES];
return vc;
}
- (UIViewController *)common_params_action:(NSDictionary *)params {
GMViewController *vc = [[GMViewController alloc] init];
if (vc.routerCompleteBlock) {
XCTAssertTrue(NO, @"common_params_action 测试失败block 不应该有值");
}
[[GMRouterTool getCurrentViewController].navigationController pushViewController:vc animated:YES];
return vc;
}
- (void)setUp {
// Put setup code here. This method is called before the invocation of each test method in the class.
NSMutableArray *targets = [NSMutableArray arrayWithArray:[GMRouter sharedInstance].targets];
[targets addObject:@"Target_GMRouterCase"];
[GMRouter sharedInstance].targets = targets;
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
- (void)testExample {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
[self testNoParamsCase];
[self testParamsCase];
[self testParams_action];
}
- (void)testNoParamsCase {
[[GMRouter sharedInstance] pushScheme:@"common_no_params"];
[[GMRouter sharedInstance] pushScheme:@"gengmei://common_no_params"];
}
- (void)testParamsCase {
[[GMRouter sharedInstance] pushScheme:@"common_params?title=无极&name=杨二&age=10"];
[[GMRouter sharedInstance] pushScheme:@"gengmei://common_params?title=无极&name=杨二&age=10"];
}
- (void)testParams_action {
UIViewController *vc = (UIViewController *)[[GMRouter sharedInstance] pushScheme:@"common_params_action" params:@{
@"title": @"无极",
@"age":@10
} completeBlock:^(NSDictionary * _Nonnull params) {
NSLog(@"收到回调");
}];
if (!vc.routerCompleteBlock) {
XCTAssertTrue(NO, @"common_params_action block 应该有值");
} else {
vc.routerCompleteBlock(@{ @"title": @"无极", @"age":@10 });
}
UIViewController *vc2 = (UIViewController *)[[GMRouter sharedInstance] pushScheme:@"common_params_action" params:@{
@"title": @"无极",
@"age":@10
} completeBlock:^(NSDictionary * _Nonnull params) {
NSLog(@"收到回调");
}];
if (!vc2.routerCompleteBlock) {
XCTAssertTrue(NO, @"common_params_action block 应该有值");
} else {
vc2.routerCompleteBlock(@{ @"title": @"无极", @"age":@10 });
}
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end
......@@ -7,30 +7,36 @@
#
Pod::Spec.new do |s|
s.name = 'GMRouter'
s.version = '0.2.8'
s.summary = 'A short description of GMRouter.'
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
更美路由
DESC
s.homepage = 'http://git.wanmeizhensuo.com/gengmeiios/GMRouter.git'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Q14' => 'qiaojinzhu@igengmei.com' }
s.source = { :git => 'git@git.wanmeizhensuo.com:gengmeiios/GMRouter.git', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.source_files = 'GMRouter/Classes/**/*'
s.dependency 'MJExtension'
s.dependency 'GMPhobos'
s.name = 'GMRouter'
s.version = '0.2.8'
s.summary = 'A short description of GMRouter.'
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
更美路由
DESC
s.homepage = 'http://git.wanmeizhensuo.com/gengmeiios/GMRouter.git'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Q14' => 'qiaojinzhu@igengmei.com' }
s.source = { :git => 'git@git.wanmeizhensuo.com:gengmeiios/GMRouter.git', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.source_files = 'GMRouter/Classes/**/*'
s.dependency 'MJExtension'
s.dependency 'GMPhobos'
s.test_spec 'GMRouterTests' do |test_spec|
test_spec.source_files = 'Tests/*.{h,m}'
test_spec.dependency 'OCMock' # This dependency will only be linked with your tests.
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment