如何在 Ax DevTools(Attest)中添加全局标签
How do I add a Global Tag in Axe DevTools (Attest)
我正在使用 Ax DevTools,我正在尝试弄清楚如何使用相同的构建信息标记多个扫描。现在我的测试 运行ning 是这样的:
class MyTestCase : XCTestCase {
func myTest() {
Attest.that(view: view)
.isAccessible({ result in })
.andPushResult(withTags: [myBuild])
}
}
如何将 myBuild
标签全局添加到我 运行 的所有测试中?
我会构建自己的 class,它利用 Ax DevTools (Attest) API。然后让我的测试用例与我自己的 class 交互,而不是与 Attest 本身交互!
class AccessibilityTestUtils {
static let buildTag:String = Bundle.main.object(
forInfoDictionaryKey: "CFBundleShortVersionString"
) as! String
init(build: String) {
self.buildTag = build
}
static func runAccessibilityTestOn(aView : View) {
Attest.that(view: aView).isAccessible({ result in })
.andPushResult(withTags: [buildTag])
}
}
用法示例
class YourTestClass {
func yourTestCase() {
AccessibilityTestUtils.runAccessibilityTestOn(aView)
}
}
注意:这种方法还可以保护您免受将来对 Attest 库的更改,使您在非向后兼容的情况下只需更改一行代码变化。
我正在使用 Ax DevTools,我正在尝试弄清楚如何使用相同的构建信息标记多个扫描。现在我的测试 运行ning 是这样的:
class MyTestCase : XCTestCase {
func myTest() {
Attest.that(view: view)
.isAccessible({ result in })
.andPushResult(withTags: [myBuild])
}
}
如何将 myBuild
标签全局添加到我 运行 的所有测试中?
我会构建自己的 class,它利用 Ax DevTools (Attest) API。然后让我的测试用例与我自己的 class 交互,而不是与 Attest 本身交互!
class AccessibilityTestUtils {
static let buildTag:String = Bundle.main.object(
forInfoDictionaryKey: "CFBundleShortVersionString"
) as! String
init(build: String) {
self.buildTag = build
}
static func runAccessibilityTestOn(aView : View) {
Attest.that(view: aView).isAccessible({ result in })
.andPushResult(withTags: [buildTag])
}
}
用法示例
class YourTestClass {
func yourTestCase() {
AccessibilityTestUtils.runAccessibilityTestOn(aView)
}
}
注意:这种方法还可以保护您免受将来对 Attest 库的更改,使您在非向后兼容的情况下只需更改一行代码变化。