Balanced XCTest Life Cycle

Test classes must implement balanced setUp and tearDown methods

  • Identifier: balanced_xctest_lifecycle
  • Enabled by default: No
  • Supports autocorrection: No
  • Kind: lint
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning
    test_parent_classes [“QuickSpec”, “XCTestCase”]

Non Triggering Examples

final class FooTests: XCTestCase {
    override func setUp() {}
    override func tearDown() {}
}
final class FooTests: XCTestCase {
    override func setUpWithError() throws {}
    override func tearDown() {}
}
final class FooTests: XCTestCase {
    override func setUp() {}
    override func tearDownWithError() throws {}
}
final class FooTests: XCTestCase {
    override func setUpWithError() throws {}
    override func tearDownWithError() throws {}
}
final class BarTests: XCTestCase {
    override func setUpWithError() throws {}
    override func tearDownWithError() throws {}
}
struct FooTests {
    override func setUp() {}
}
class BarTests {
    override func setUpWithError() throws {}
}
final class FooTests: XCTestCase {
    override func setUpAlLExamples() {}
}
final class FooTests: XCTestCase {
    class func setUp() {}
    class func tearDown() {}
}

Triggering Examples

final class FooTests: XCTestCase {
    override func setUp() {}
}
final class FooTests: XCTestCase {
    override func setUpWithError() throws {}
}
final class FooTests: XCTestCase {
    override func setUp() {}
    override func tearDownWithError() throws {}
}
final class BarTests: XCTestCase {
    override func setUpWithError() throws {}
}
final class FooTests: XCTestCase {
    class func tearDown() {}
}
final class FooTests: XCTestCase {
    override func tearDown() {}
}
final class FooTests: XCTestCase {
    override func tearDownWithError() throws {}
}
final class FooTests: XCTestCase {
    override func setUp() {}
    override func tearDownWithError() throws {}
}
final class BarTests: XCTestCase {
    override func tearDownWithError() throws {}
}