OC 单元测试学习笔记

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OC 单元测试学习笔记相关的知识,希望对你有一定的参考价值。

UnitTest 编译异常汇总:

问题1

Check dependencies

No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).

经过与正常 test target 设置比较,默认设置中 Debug architecture 只有armv7 添加 arm64以后 Test build 即成功;

问题2

ld: -bundle_loader can only be used with -bundle

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Mach-O mac OS 上的可执行文件格式,在xcode help 文档中,具体是这样描述的,测试target 需选择 Bundle

问题3

test target 碰到如下错误:

 ld: entry point (_main) undefined. for architecture armv7

clang: error: linker command failed with exit code 1 (use -v to see invocation)

 

在test target 中 , General Tab, 把 Allow testing Host Application APIs 复选框勾上即解决了此问题。

 

附录:

Mach-O Type (MACH_O_TYPE)

This setting determines the format of the produced binary and how it can be linked when building other binaries. For information on binary types, see Building Mach-O Files in Mach-O Programming Topics.

  • Executable: Executables and standalone binaries and cannot be linked. mh_execute
  • Dynamic Library: Dynamic libraries are linked at build time and loaded automatically when needed. mh_dylib
  • Bundle: Bundle libraries are loaded explicitly at run time. mh_bundle
  • Static Library: Static libraries are linked at build time and loaded at execution time. staticlib
  • Relocatable Object File: Object files are single-module files that are linked at build time. mh_object

以上是关于OC 单元测试学习笔记的主要内容,如果未能解决你的问题,请参考以下文章

JUnitJava 单元测试框架 | 学习笔记

python + unittest 做单元测试之学习笔记

python学习笔记9-单元测试unittest

Python学习笔记__8.3章 单元测试

学习笔记单元测试之mockito学习笔记

软件工程学习笔记一:单元测试