简体   繁体   English

如何将标签/属性添加到 XCUITest(Swift)

[英]How to add tag/attributes to XCUITest(Swift)

I am trying to figure out if we have any way to set Tag/Attribute to tests in Swift.我想弄清楚我们是否有任何方法可以将标记/属性设置为 Swift 中的测试。 In C# we use to tag test based on feature and test type that use to help us in reporting.在 C# 中,我们使用基于功能和测试类型来标记测试,以帮助我们进行报告。 Below is the example:-以下是示例:-

[Category("LongRunning"),Category("Workspace")] public class LongRunningTests {... } [Category("LongRunning"),Category("Workspace")] public class LongRunningTests {... }

Any help is appreciated.任何帮助表示赞赏。

There are no built-in options to no annotate test cases and test classes in Swift. Swift 中没有内置选项可以不注释测试用例和测试类。

You shall add Dictionary containing tests names and their groups in your custom XCTestCase and override invokeTest() based on this Dictionary.您应在自定义 XCTestCase 中添加包含测试名称及其组的 Dictionary,并基于此 Dictionary 覆盖 invokeTest()。

Your annotations may look something like this:您的注释可能如下所示:

class TestClass: CustomUITestCase {

    override var testClassesGrouping: [TestClassesGroups] { return  [.positiveScenarios] }
    override var testCasesGrouping: [String: [TestCasesGroups]] { return
        ["testReminderWithNotes": [.testSettingNotes],
         "testPastReminder": [.testChangingDate],
         "testFutureReminder": [.testChangingDate],
         "testFuturePrioritised": [.testChangingDate, .testSettingPriority],
         "testPrioritisedReminder": [.testSettingPriority]]
    }
    ... 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM