Home > Back-end >  Quick Nimble ios test not running
Quick Nimble ios test not running

Time:04-13

I'm trying to use Quick & Nimble to test a project but the test is never executed.

I've created a project from scratch using File->New->Project in Xcode. The project is called "MyApp". Then I created a UnitTest target testing "MyApp".

I've added the following Podfile:

use_frameworks!
inhibit_all_warnings!

target 'MyApp' do
  # Pods for Test
  target "MyAppTests" do
  
      pod 'Quick'
      pod 'Nimble'
    end
end

I ran "pod install" and everything went well.

Then, I've created a test file:

import Quick
import Nimble
@testable import MyApp

class TestSpec: QuickSpec {

    override func spec() {
        describe("Describe test") {
            context("Context test") {
                it("Assertion") {
                    expect("toto") == "tata"
                }
            }
        }
    }

}

Then I ran the test. I expected my test to fail but actually: nothing. It's never executed. Do you guys have any idea why?

Thanks a lot.

CodePudding user response:

If you are trying to compare string toto to string tata for testing purposes. You could easily achieve this by adding the following changes. expect("toto").to(equal("tata"))

I have tested your providing sample code. It's working fine in my case.

    import Quick
    import Nimble
    @testable import NimbleSpec
    
    class TestSpec: QuickSpec {

    override func spec() {
        describe("Describe test") {
            context("Context test") {
                it("Assertion") {
                    expect("toto").to(equal("tata"))
                }
            }
        }
    }
}

The following suggestions might help newbies like me who is new to Xcode.

In order to properly check the unit test file go to Show the test navigator from Show the project navigator

After that click the file or project which are you gonna test and press media icon which is near to file/ project name. Here is an example.

enter image description here

CodePudding user response:

Quick/Nimble test has a related bug for Xcode 13.3. I tested both 13.3 and 13.2.1 and only 13.2.1 can run Nimble tests. Might have to wait for the fix to be merged.

  • Related