Skip to content

Files

Latest commit

 

History

History
66 lines (43 loc) · 914 Bytes

empty_xctest_method.md

File metadata and controls

66 lines (43 loc) · 914 Bytes

Pattern: Empty XCTest method

Issue: -

Description

Empty XCTest method should be avoided.

Examples of correct code:

class TotoTests: XCTestCase {
    var foobar: Foobar?

    override func setUp() {
        super.setUp()
        foobar = Foobar()
    }

    override func tearDown() {
        foobar = nil
        super.tearDown()
    }

    func testFoo() {
        XCTAssertTrue(foobar?.foo)
    }

    func testBar() {
        // comment...

        XCTAssertFalse(foobar?.bar)

        // comment...
    }
}

Examples of incorrect code:

class TotoTests: XCTestCase {
    override func setUp() {
    }

    overridefunc tearDown() {

    }

    func testFoo() {


    }

    func testBar() {


    }

    func helperFunction() {
    }
}

Further Reading