Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Quick/Nimble tests not running

I'm trying to do a simple test to see if Quick and Nimble are working properly, but they're not. Here is my simple test which is supposed to break:

import Quick
import Nimble

class SomeSpec: QuickSpec {
    override func spec() {
        describe("bad test") {
            it("does not pass") {
                expect("good").to(equal("bad"))
            }
        }
    }
}

But if I run the test, I'll see output:

Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.004) seconds

I don't know why zero tests are being run. I did install Quick and Nimble with Swift Package Manager instead of Cocoapods, if that might be a reason for the problem.

like image 667
elveatles Avatar asked Oct 29 '22 16:10

elveatles


2 Answers

To anyone still having an issue, it's already addressed in the latest Quick release - but unless you point version, default pod install installs Quick 4.0.0, while version 5.0.1 is already available. So add this to the podfile:

 pod 'Quick', '~> 5.0.1'

and it should work.

like image 102
Async- Avatar answered Nov 15 '22 05:11

Async-


It sounds like the test class is not part of the test target, therefore it's not being run. Try deleting and re-adding it as per 'Xcode Help > Add a test class to a project'.

And here are the steps to run this test successfully in a brand new project:

  1. Create a new project (for demo purposes, on the options screen, uncheck 'Include Unit Tests'.
  2. Add a test target as per 'Add a test target to a project'.
  3. Add Quick and Nimble pods to the test target.
  4. Add a test class as per 'Xcode Help > Add a test class to a project'.
  5. Replace the content of the test class file with your snippet above.
  6. Run the tests ('Product > Test').
like image 24
buildc0de Avatar answered Nov 15 '22 07:11

buildc0de