Tuist为Sourcery生成命令行选项的插件
图伊斯特源插件
一个扩展Tuist并为给定模块调用Sourcery的插件。需要安装源:brew install sourcery
例如:
tuist sorcery --project-path <path/to/project> --template-path SourceryTemplates --output-path Tests/Mocks Home
当在与项目相同的目录中运行时,存在一个名为 SourceryTemplates 的目录,其中包含模具,然后命令可以缩短为
tuist sourcery Home
在示例项目中,项目依赖于 ,因此它将包含在传递给 Sourcery 的源中。Home
Common
用法
插件需要在 Config.swift 文件中定义。
let config = Config(
plugins: [.git(url: "https://github.com/ronanociosoig-200/SourceryPlugin", tag: "0.1.0")]
)
更新后,运行以安装它。tuist fetch
该插件根据对目标依赖项的迭代为所有源生成所有路径。然后生成后,它会为每个依赖项插入@testable import
它假设所有模块都在路径 ./Core 下,并且所有功能模块都在 ./Features下,并且任何功能模块都不能依赖于另一个功能模块。这只是一个概念证明,如果你想使用它,你必须更新一些在顶部定义的常量Sources/TuistSourceryPlugin/Commands/GenerateCommand.swift
参数
论点 | 短 | 描述 | 违约 | 必填 |
---|---|---|---|---|
--project-path |
-p |
包含项目.swift的目录的路径。如果未指定,则使用当前目录。如果未找到项目,它将退出。 | ./ |
不 |
--template-path |
-t |
源模板的路径。如果未指定,则使用默认的源模板。模板必须命名为 AutoMockable.stencil | 源模板 | 不 |
--output-path |
-o |
输出的路径。如果未指定,它将使用默认的测试/模拟。 | 测试/模拟 | 不 |
--debug |
-d |
Show debug information. | – | No |
--help |
-h |
Show help information. | – | No |
Testing The Project
Download and open Package.swift. Wait for the Swift packages to load, and for Xcode to work out this is a Mac project and have a target to run. Edit the scheme and add launch arguments
–project-path /path-to-project/Tests/Example/Pokedex/ Home
This will generate the mocks at Pokedex/Features/Home/Tests/Mocks/AutoMockable.generated.swift
As this source file is already added to the repo, delete it, and note that it is generated again.
The binary generated is here: DerivedData/SourceryPlugin/Build/Products/Debug