Swift unit tests mock class static method : <p>I have a static method in class</p>

<pre><code>class A {
    static func myStaticMethod() -&gt; B {
        return B()
    }
}

class B {
    func getTitle() -&gt; String {
        // some functionality here
    }
}
</code></pre>

<p>In my class method that i want to test i use it like:</p>

<pre><code>func someBoolFunc() -&gt; Bool {
    var b = A.myStaticMethod()
    if (b.getTitle() = “hello”) {
         return true
    }
    return false
}
</code></pre>

<p>How to write mock class for this... I tried:</p>

<pre><code>class MockA: A {
    var myTitle:String
    // this seems incorrect, because i didn't override static function
    func myStaticMethod() -&gt; MockB {
        var b = MockB()
        b.title = myTitle
        return b
    }
}

class MockB: B {
    var myTitle:String    

    func getTitle() -&gt; String {

        return myTitle
    }
}
</code></pre>

<p>And in tests i wanted to use something like:</p>

<pre><code>func testExample() {
    A = MockA
    MockA.title = "My title"
    // And now this func should use my MockA instead of A
    someBoolFunc()
}
</code></pre>

<p>But of course it is only in theory :(</p>
