|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +public struct TestTag: Codable, Equatable, Sendable { |
| 14 | + /// ID of the test tag. `TestTag` instances with the same ID are considered to be identical. |
| 15 | + public let id: String |
| 16 | + |
| 17 | + public init(id: String) { |
| 18 | + self.id = id |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +/// A test item that can be shown an a client's test explorer or used to identify tests alongside a source file. |
| 23 | +/// |
| 24 | +/// A `TestItem` can represent either a test suite or a test itself, since they both have similar capabilities. |
| 25 | +public struct TestItem: ResponseType, Equatable { |
| 26 | + /// Identifier for the `TestItem`. |
| 27 | + /// |
| 28 | + /// This identifier uniquely identifies the test case or test suite. It can be used to run an individual test (suite). |
| 29 | + public let id: String |
| 30 | + |
| 31 | + /// Display name describing the test. |
| 32 | + public let label: String |
| 33 | + |
| 34 | + /// Optional description that appears next to the label. |
| 35 | + public let description: String? |
| 36 | + |
| 37 | + /// A string that should be used when comparing this item with other items. |
| 38 | + /// |
| 39 | + /// When `nil` the `label` is used. |
| 40 | + public let sortText: String? |
| 41 | + |
| 42 | + /// The location of the test item in the source code. |
| 43 | + public let location: Location |
| 44 | + |
| 45 | + /// The children of this test item. |
| 46 | + /// |
| 47 | + /// For a test suite, this may contain the individual test cases or nested suites. |
| 48 | + public let children: [TestItem] |
| 49 | + |
| 50 | + /// Tags associated with this test item. |
| 51 | + public let tags: [TestTag] |
| 52 | + |
| 53 | + public init( |
| 54 | + id: String, |
| 55 | + label: String, |
| 56 | + description: String? = nil, |
| 57 | + sortText: String? = nil, |
| 58 | + location: Location, |
| 59 | + children: [TestItem], |
| 60 | + tags: [TestTag] |
| 61 | + ) { |
| 62 | + self.id = id |
| 63 | + self.label = label |
| 64 | + self.description = description |
| 65 | + self.sortText = sortText |
| 66 | + self.location = location |
| 67 | + self.children = children |
| 68 | + self.tags = tags |
| 69 | + } |
| 70 | +} |
0 commit comments