- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想认为我理解继承的概念,但显然我不理解,因为我很困惑如果 XCTest 在其类中提供设置方法,为什么在 XCTestCase 中有设置方法? XCTestCase 是 XCTest 的子类,但在阅读 Apple 文档后,两者之间看起来没有任何区别。
import XCTest
@testable import FirstDemo
class FirstDemoTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}
最佳答案
XCTest 是一个基类,具有空的 setUp()
和 tearDown()
方法。
XCTestCase 继承自 XCTest,因此它继承了那些相同的方法。它没有自己的实现。无论如何,它们只是无所事事的方法。它们的定义只是为了让我们可以覆盖它们。这是 Template Method design pattern 的示例.
为什么要在 XCTest 中定义这些方法,或者根本没有 XCTest?测试运行器可以使用 XCTest 的子类的任何东西,并且对 XCTestCase 一无所知。这可能允许我们定义定义测试套件的新方法,而不是 XCTestCase 子类,同时仍然与 XCTest 框架集成。
有关 xUnit 架构的更多信息,请参阅 JUnit: A Cook's Tour
关于ios - 为什么XCTestCase会覆盖XCTest的setup方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43104693/
我有一个使用 XCTest 框架的 CocoaPod。为了将 XCTest 导入 pod,我将 s.frameworks = 'XCTest' 添加到 .podspec 文件。 我现在可以将 XCTe
我正在尝试在 iphone 设备上运行 XCTest,但 Xcode 显示以下消息。 "Logic Testing on iOS devices is not supported. You can r
我认为,我在那里找到的关于主题的所有信息都是有用的信息,但我需要了解更小的步骤。我如何创建测试,如何单击并滑动浏览应用程序中的一些文章,如何测试长按手势,..请提供一些有助于初学者的小示例,谢谢。 最
我正在尝试在 Xcode 中开始使用 tdd,并遵循了一个非常好的 tutorial . 一切顺利。但是,当我想在 Xcode 中创建命令行应用程序(在 c 中)项目时,未创建单独的测试文件夹。 我想
我使用查找器将一些图像(选项卡图标)添加到我的应用程序的目录中,然后使用文件添加将它们添加到项目中,最后在 images.xcassets 中添加图像集,将它们拖到上方以用作选项卡图标。 不知何故,在
在重命名之前,我首先复制了我的项目。重命名后我得到了 Lexical or Preprocessor Issue not found. 错误将我引导至调用 的 myapptests.m 文件 #im
XCTest waitForExpectationsWithTimeout:handler: 的文档指出 Only one -waitForExpectationsWithTimeout:handle
从Xcode Beta 5在iOS 8上运行测试时因以下错误而崩溃: dyld: Symbol not found: _kAXXCAttributeAbsoluteValue Referenced
例如,在使用 icloud 数据填充本地数据的测试成功之前,我不想运行从我的本地数据中选择的函数的测试。 我认为一个合适的单元测试应该在测试本地数据选择方法之前编写一些预定义的本地数据(人们同意吗?)
尝试使用 cocoa pods 将库集成到我的项目时出现以下异常。 dyld:未加载库:@rpath/XCTest.framework/XCTest 引用自:/Users/shoaibahmedqur
我是 ios 世界的新手,正在弄清楚如何从命令行运行测试。 我有 APP.app 和 TEST.xctest(基本上是 KIF 测试)。 我无法弄清楚如何在应用程序(在模拟器和设备上)上运行这些测试。
我觉得我有一个很常见的问题,但不知何故错过了关于最佳实践的备忘录。我想弄清楚如何在 XCTest 中嵌套异步调用。 我正在尝试通过基于 Alamofire 的 REST API 测试/清理 XCTes
我有几个项目正在尝试使用 Xcode 6 Beta 2 构建。这些项目都有某种类型的库使用 XCTest(Kiwi/XCTest 和 Specta),这些库不能在 Xcode 6 中构建,因为 XCT
谁能给我解释一下这里发生了什么?我不明白这个错误是什么意思。 XCTest.framework/XCTest: no matching architecture in universal wrappe
我在此处关注有关使用钥匙串(keychain)的教程 http://code.tutsplus.com/tutorials/securing-and-encrypting-data-on-ios--m
我在Xcode 5.0.2中运行项目时遇到问题 我收到以下错误: dyld: Library not loaded: @rpath/XCTest.framework/Versions/A/XCTest
所以,这是错误,我记录了我的 UI 脚本,但是当我重放 UI 脚本时发生了错误。控制台显示: “dyld:未加载库:@rpath/XCTest.framework/XCTest 引用自:/var/co
我在 中导入了我的旧项目Xcode 6.1 并且上面提到的错误在运行时开始出现,原因是 图片未找到 ,我已经尝试了以下链接中建议的所有答案 Xcode 5.0.2 dyld error 但到目前为止,
在 OS X 10.9.5 中,我从 Xcode 5.1.1 升级到 Xcode 6.0.1(通过 App Store)。 现在在我的项目中 XCTest.framework和 MyAppTests.
在我们的 Jenkins CI slave 上的 iOS 应用程序上运行 UI 测试时,UI 不正确并且我的测试失败。在本地,相同的 UI 符合预期并且测试通过。 我一直无法弄清楚这一点,也无法像在远
我是一名优秀的程序员,十分优秀!