传感器:iOS开发的全新视角

  • Z7_306628
    了解作者
  • 37.6MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-13 05:45
    上传日期
传感器 如今,移动应用程序变得越来越强大和复杂,其丰富的功能试图改善用户的体验。 但是,没有控制力,力量无非是:应用程序越强大(和复杂),最终导致出现不一致状态的机会就越大。 好消息是我们的传感器架构:一种在处理复杂应用程序时组织代码的优雅且不错的方法。 具有定义移动应用程序每个功能的所有可能状态的能力,最终出现不一致状态的可能性极小。 借助状态机的概念及其确定性的行为,我们可以确保从一个状态到另一个状态的所有转换都受到一组可能发生的有限事件的调节。 Sensor框架随附电池,因此您可以立即开始编写安全的应用程序。 SensorTest框架包含一些优点,可帮助您轻松编写单元测试。 了解更多 建立 椰子足 要使用Sensor框架,请将以下行添加到Podfile上的应用程序目标中: pod 'Sensor', '0.1.1' 在您的应用中,添加以下导入: import Sensor 要使用SensorTest框架,请将以下行添加到Podfile上的测试目标: pod 'SensorTest', '0.1.1' 在测试中,添加以下导入: import SensorTes
Sensor-master.zip
内容介绍
# Nimble [![Build Status](https://travis-ci.org/Quick/Nimble.svg?branch=master)](https://travis-ci.org/Quick/Nimble) [![CocoaPods](https://img.shields.io/cocoapods/v/Nimble.svg)](https://cocoapods.org/pods/Nimble) [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Platforms](https://img.shields.io/cocoapods/p/Nimble.svg)](https://cocoapods.org/pods/Nimble) [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com) Use Nimble to express the expected outcomes of Swift or Objective-C expressions. Inspired by [Cedar](https://github.com/pivotal/cedar). ```swift // Swift expect(1 + 1).to(equal(2)) expect(1.2).to(beCloseTo(1.1, within: 0.1)) expect(3) > 2 expect("seahorse").to(contain("sea")) expect(["Atlantic", "Pacific"]).toNot(contain("Mississippi")) expect(ocean.isClean).toEventually(beTruthy()) ``` # How to Use Nimble <!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* - [Some Background: Expressing Outcomes Using Assertions in XCTest](#some-background-expressing-outcomes-using-assertions-in-xctest) - [Nimble: Expectations Using `expect(...).to`](#nimble-expectations-using-expectto) - [Custom Failure Messages](#custom-failure-messages) - [Type Safety](#type-safety) - [Operator Overloads](#operator-overloads) - [Lazily Computed Values](#lazily-computed-values) - [C Primitives](#c-primitives) - [Asynchronous Expectations](#asynchronous-expectations) - [Objective-C Support](#objective-c-support) - [Disabling Objective-C Shorthand](#disabling-objective-c-shorthand) - [Built-in Matcher Functions](#built-in-matcher-functions) - [Type Checking](#type-checking) - [Equivalence](#equivalence) - [Identity](#identity) - [Comparisons](#comparisons) - [Types/Classes](#typesclasses) - [Truthiness](#truthiness) - [Swift Assertions](#swift-assertions) - [Swift Error Handling](#swift-error-handling) - [Exceptions](#exceptions) - [Collection Membership](#collection-membership) - [Strings](#strings) - [Collection Elements](#collection-elements) - [Collection Count](#collection-count) - [Notifications](#notifications) - [Matching a value to any of a group of matchers](#matching-a-value-to-any-of-a-group-of-matchers) - [Custom Validation](#custom-validation) - [Writing Your Own Matchers](#writing-your-own-matchers) - [PredicateResult](#predicateresult) - [Lazy Evaluation](#lazy-evaluation) - [Type Checking via Swift Generics](#type-checking-via-swift-generics) - [Customizing Failure Messages](#customizing-failure-messages) - [Basic Customization](#basic-customization) - [Full Customization](#full-customization) - [Supporting Objective-C](#supporting-objective-c) - [Properly Handling `nil` in Objective-C Matchers](#properly-handling-nil-in-objective-c-matchers) - [Migrating from the Old Matcher API](#migrating-from-the-old-matcher-api) - [Minimal Step - Use `.predicate`](#minimal-step---use-predicate) - [Convert to use `Predicate` Type with Old Matcher Constructor](#convert-to-use-predicate-type-with-old-matcher-constructor) - [Convert to `Predicate` Type with Preferred Constructor](#convert-to-predicate-type-with-preferred-constructor) - [Deprecation Roadmap](#deprecation-roadmap) - [Installing Nimble](#installing-nimble) - [Installing Nimble as a Submodule](#installing-nimble-as-a-submodule) - [Installing Nimble via CocoaPods](#installing-nimble-via-cocoapods) - [Using Nimble without XCTest](#using-nimble-without-xctest) <!-- END doctoc generated TOC please keep comment here to allow auto update --> # Some Background: Expressing Outcomes Using Assertions in XCTest Apple's Xcode includes the XCTest framework, which provides assertion macros to test whether code behaves properly. For example, to assert that `1 + 1 = 2`, XCTest has you write: ```swift // Swift XCTAssertEqual(1 + 1, 2, "expected one plus one to equal two") ``` Or, in Objective-C: ```objc // Objective-C XCTAssertEqual(1 + 1, 2, @"expected one plus one to equal two"); ``` XCTest assertions have a couple of drawbacks: 1. **Not enough macros.** There's no easy way to assert that a string contains a particular substring, or that a number is less than or equal to another. 2. **It's hard to write asynchronous tests.** XCTest forces you to write a lot of boilerplate code. Nimble addresses these concerns. # Nimble: Expectations Using `expect(...).to` Nimble allows you to express expectations using a natural, easily understood language: ```swift // Swift import Nimble expect(seagull.squawk).to(equal("Squee!")) ``` ```objc // Objective-C @import Nimble; expect(seagull.squawk).to(equal(@"Squee!")); ``` > The `expect` function autocompletes to include `file:` and `line:`, but these parameters are optional. Use the default values to have Xcode highlight the correct line when an expectation is not met. To perform the opposite expectation--to assert something is *not* equal--use `toNot` or `notTo`: ```swift // Swift import Nimble expect(seagull.squawk).toNot(equal("Oh, hello there!")) expect(seagull.squawk).notTo(equal("Oh, hello there!")) ``` ```objc // Objective-C @import Nimble; expect(seagull.squawk).toNot(equal(@"Oh, hello there!")); expect(seagull.squawk).notTo(equal(@"Oh, hello there!")); ``` ## Custom Failure Messages Would you like to add more information to the test's failure messages? Use the `description` optional argument to add your own text: ```swift // Swift expect(1 + 1).to(equal(3)) // failed - expected to equal <3>, got <2> expect(1 + 1).to(equal(3), description: "Make sure libKindergartenMath is loaded") // failed - Make sure libKindergartenMath is loaded // expected to equal <3>, got <2> ``` Or the *WithDescription version in Objective-C: ```objc // Objective-C @import Nimble; expect(@(1+1)).to(equal(@3)); // failed - expected to equal <3.0000>, got <2.0000> expect(@(1+1)).toWithDescription(equal(@3), @"Make sure libKindergartenMath is loaded"); // failed - Make sure libKindergartenMath is loaded // expected to equal <3.0000>, got <2.0000> ``` ## Type Safety Nimble makes sure you don't compare two types that don't match: ```swift // Swift // Does not compile: expect(1 + 1).to(equal("Squee!")) ``` > Nimble uses generics--only available in Swift--to ensure type correctness. That means type checking is not available when using Nimble in Objective-C. :sob: ## Operator Overloads Tired of so much typing? With Nimble, you can use overloaded operators like `==` for equivalence, or `>` for comparisons: ```swift // Swift // Passes if squawk does not equal "Hi!": expect(seagull.squawk) != "Hi!" // Passes if 10 is greater than 2: expect(10) > 2 ``` > Operator overloads are only available in Swift, so you won't be able to use this syntax in Objective-C. :broken_heart: ## Lazily Computed Values The `expect` function doesn't evaluate the value it's given until it's time to match. So Nimble can test whether an expression raises an exception once evaluated: ```swift // Swift // Note: Swift currently doesn't have exceptions. // Only Objective-C code can raise exceptions // that Nimble will catch. // (see https://github.com/Quick/Nimble/issues/220#issuecomment-172667064) let exception = NSException( name: NSInternalInconsistencyException, reason: "Not enough fish in the sea.", userInfo: ["something": "is fishy"]) expect { exception.raise() }.to(raiseException()) // Also, you can customize raiseException to be more specific expect { exception.raise() }.to(raiseException(named: NSInternalInconsistencyException)) expect { exception.raise() }.to(raiseException( named: NSInternalInconsistencyException, reason: "Not
评论
    相关推荐
    • LabVIEW单元测试架构工具包(英文版).rar
      LabVIEW单元测试架构工具包(英文版)rar,使用LabVIEW软件设计工具,可以保证高品质以及稳定应用。单元测试架构可以运行自动软件测试,复原测试以及最后确认。为了更好的下载和评估NI LabVIEW单元测试架构,您需先购买...
    • sqrt:测试软件基础架构工具和思想的平台
      SQRT 用Fortran编写的基本平方根计算程序,它为评估各种软件基础结构工具和思想提供了基础。 此处演示的方法: CMake的编译器指令 这可以简单地用类似的方法完成 ...我选择在此处评估和实施的单元测试框架是NASA Godd
    • 分层架构单元测试
      分层架构下的单元测试,使用Mock的机制剥离依赖关系
    • gtest单元测试框架
      自己根据需求写的一个c++单元测试框架,写这个基础是阅读了gtest源码和许多架构,和为了方便大家的需要,写的一个通用性框架。如果大家需要,可以修改里面的相关代码,实现自己的独特需求。
    • Flex持续集成之单元测试
      Flex持续集成之单元测试
    • 单元测试架构工具包与执行跟踪工具包.zip
      单元测试架构工具包与执行跟踪工具包zip,本讲主要为您介绍单元测试架构工具包与执行跟踪工具包的具体使用。欲了解更多LabVIEW相关信息,请点击ni.com/LabVIEW 分类:在线视频
    • MVP架构开发中应用GooglTest进行单元测试的Demo
      MVP架构开发中应用GooglTest进行单元测试的Demo 在UI开发中,经常使用MVP(MVC)模式进行界面和业务的逻辑解耦 MVP模式的一个优势是方便对M层和P层进行单元测试 在本Demo中提供了对MVP模式的P层进行单元测试的使用...
    • TDD单元测试
      TDD 测试
    • 单元测试架构工具包与执行跟踪工具包后续资源包.zip
      欢迎下载LabVIEW网络讲坛之单元测试架构工具包与执行跟踪工具包后续资源包,内含此次视频的相关例程以及演讲讲义. 欲了解
    • cppunit单元测试
      cppunit进行单元测试框架构建与gtest的单元测试框架构建