跳至主要内容

博文

目前显示的是 七月, 2020的博文

Jenkins实现iOS自动化测试及覆盖率报告输出

原文链接 一、Jenkins安装,Xcode插件安装 略 二、Xcode工程准备 Xcode工程(这里我用的是workspace)包含两个Target,一个是UnitTest项目 工程Target 打开Xcode左上角Manage Schemes,将Shared打钩 Scheme设置 选中项目的Scheme点击左下角Edit,打开Gather coverage data,打开覆盖率收集,在Debug模式下会收集覆盖率报告。 打开覆盖率收集 写好UnitTestCase,command+u跑一下,在Xcode里可以看到用例结果报告和覆盖率报告。 测试结果报告 覆盖率报告 三、集成到Jenkins实现自动化测试 新建Job,设置源码branch,这里最好新建一个专门用于测试的branch,这里取名unittest。 新建Job 设置源码 设置构建触发器 */5 * * * * ,每5分钟检查一次源码变化。 设置构建触发器 增加构建步骤,选择Execute shell脚本 构建脚本 输入脚本: #!/bin/bash -l #新建目录用于保存报告 mkdir test-reports #pod可能失败的全局参数设置 export LANG=en_US.UTF-8 export LANGUAGE=en_US.UTF-8 export LC_ALL=en_US.UTF-8 pod install #xcodebuild test -workspace XXX.xcworkspace -scheme XXXTests -destination 'platform=iOS Simulator,name=iPhone 6s'跑测试用例 #-enableCodeCoverage YES 收集测试覆盖率 #ocunit2junit 输出报告转换为jenkins可读的junit报告 xcodebuild test -workspace XXX.xcworkspace -scheme XXXTests -destination 'platform=iOS Simulator,name=iPhone 6s...

Basic Continuous Integration with Jenkins, Xcode, and GitHub

原文链接 In my last article , I made the case for why unit tests and code reviews are  valuable. In this one, I’m going to show you how to set up an automated system to enforce those principles. Before allowing a PR to be merged, we’re going to require someone to review it and that all unit tests have passed. Shouldn’t developers be running unit tests before submitting a PR? Yes, but there’s no shame in having guard rails. It’s common for experts to forget a detail or two.  Look at what happened when a hospital started allowing nurses to enforce checklists on doctors. In 2001, a critical-care specialist at Johns Hopkins Hospital named Peter Pronovost decided to give [the checklist] a try…he and his team persuaded the hospital administration to authorize nurses to stop doctors if they saw them skipping a step on the checklist… Pronovost and his colleagues monitored what happened for a year afterward. The results were so dramatic that they weren’t sure whether to believe them: ...

Creating Swift frameworks for iOS, OS X and tvOS with Unit Tests and Distributing via CocoaPods and Swift Package Manager

原文链接 There are many ways to make code easily reusable in Apple platforms. For instance, although not highly recommendable, code can easily be placed in Swift files and copied from one project to another. This method works well in general, but it is hard to manage versions and it is prone to errors. Introduction to Frameworks and Package Managers Traditionally, on Apple platforms, reusable code will be packed and distributed as  frameworks  (bundled files with extension  .framework ). In the last few years, other package managers have become very popular, like  CocoaPods ,  Carthage  or the new  Swift Package Manager . These package managers do not require for the code to be put inside a framework. They can pack and distribute the code directly without the need for any project whatsoever. However, in my experience,  I have found some major benefits when using frameworks for my libraries and SDKs : Frameworks can include Unit Tests without the need ...