Private Unit Test

Unit tests marked private are silently skipped

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

Non Triggering Examples

class FooTest: XCTestCase {
    func test1() {}
    internal func test2() {}
    public func test3() {}
}
internal class FooTest: XCTestCase {
    func test1() {}
    internal func test2() {}
    public func test3() {}
}
public class FooTest: XCTestCase {
    func test1() {}
    internal func test2() {}
    public func test3() {}
}
@objc private class FooTest: XCTestCase {
    @objc private func test1() {}
    internal func test2() {}
    public func test3() {}
}
private class Foo: NSObject {
    func test1() {}
    internal func test2() {}
    public func test3() {}
}
private class Foo {
    func test1() {}
    internal func test2() {}
    public func test3() {}
}
public class FooTest: XCTestCase {
    private func test1(param: Int) {}
    private func test2() -> String { "" }
    private func atest() {}
    private static func test3() {}
}

Triggering Examples

private class FooTest: XCTestCase {
    func test1() {}
    internal func test2() {}
    public func test3() {}
    private func test4() {}
}
class FooTest: XCTestCase {
    func test1() {}
    internal func test2() {}
    public func test3() {}
    private func test4() {}
}
internal class FooTest: XCTestCase {
    func test1() {}
    internal func test2() {}
    public func test3() {}
    private func test4() {}
}
public class FooTest: XCTestCase {
    func test1() {}
    internal func test2() {}
    public func test3() {}
    private func test4() {}
}