我想做的是在对文件进行微小更改后经常测试 Swift 文件。该文件可能包含一个或多个结构和类。
我不关心“应用程序”的概念,因为这纯粹是一种学术练习,用于练习我学到的一些新概念。我只想测试文件,不关心应用程序以及与应用程序相关的任何内容。
您可能会问为什么?速度。我希望它的测试速度非常快,现在最简单的例子需要几秒钟。我看到它在构建目标方面做了很多工作:
最佳答案
你应该试试 Swift Playground。
这是在 developer.apple.com/swift 的描述:
Interactive Playgrounds
Playgrounds make writing Swift code incredibly simple and fun. Type a line of code and the result appears immediately. If your code runs over time, for instance through a loop, you can watch its progress in the timeline assistant. The timeline displays variables in a graph, draws each step when composing a view, and can play an animated SpriteKit scene. When you’ve perfected your code in the playground, simply move that code into your project. Some uses for playgrounds include:
Design a new algorithm, watching its results every step of the way
Create new tests, verifying they work before promoting into your test suite
Experiment with new APIs to hone your Swift coding skills
关于xcode - 如何使用 XCTest 在 Xcode 中测试 Swift 文件而无需构建整个应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28128169/