Skip to content

Xcode templates for JDAppTests which can add unit tests on devices.

License

Notifications You must be signed in to change notification settings

JiandanDream/JiandanDev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JiandanDev

Xcode templates for JDAppTests which can add unit tests on devices.

本项目是 Xcode 工程模板:JDAppTests,是对 Single View App 模板的修改。

开发 JDAppTests 的起因是 XCTest 无法在真机上进行单元测试。

所以有了这样一个工具,它是对 XCTests 的补充,实质是一个 App 工程。

主要满足在真机上进行单元测试的需求,一般用于对 Framework 的测试。

真机单元测试工具 JDAppTests 实现原理

How To Get Started

Install

sudo git clone --recursive https://github.com/JiandanDream/JiandanDev.git /opt/JiandanDev

Add templates

ln -sv /opt/JiandanDev/templates ~/Library/Developer/Xcode/Templates/JiandanDev

Restart Xcode

Usage

Add a Target in Xcode and choose JDAppTests from the templates.

Xcode 中新建一个 Target,选择 JDAppTests,创建一个 App 工程的 Target。

AddTarget

Add a Cocoa Touch Class, subclass of JDAppTestCase.

创建一个类,继承自 JDAppTestCase。

Add methods with prefix test.

添加测试方法:必须以 test 开头。

e.g.

//.h
#import "JDAppTestCase.h"

@interface NetRequestAppTests : JDAppTestCase

@end

//.m
#import "NetRequestAppTests.h"

@implementation NetRequestAppTests
- (void)testPOST {
    NSLog(@"POST");
}
@end

If in Swift, you can add methods like this.

若使用 Swift,可以这样添加测试方法:

// XXAppTests-Bridging-Header.h
#import "JDAppTestCase.h"
@testable import XX

class SAppTests: JDAppTestCase {
    @objc func testSS() {
        print("ss")
    }
}

Run

Example

Like XCTest, you can add any test methods quickly.

跟 XCTest 类似,添加测试用例时,无需其他修改,可以方便快捷地测试某个方法。

About

Xcode templates for JDAppTests which can add unit tests on devices.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published