5

I have problem with unit testing. When I run tests, it ends up with "No tests found". I am using AppCode and Quick/Nimble framework for unit testing, but it doesn't work in XCode either.

I have XCTest/Kiwi run configuration with Target: MyAppTests, Configuration: Development and Class: All test classes (it doesn't work even with particular test class specified). Nothing much more configured as far as I know.

Any ideas what I am doing wrong? I am not sure what other kind of info/configuration I should provide.. thanks

Edit: Sample unit test code

import Quick
import Nimble
@testable import FigurePOS

class DateFormatterTest: QuickSpec
{
    override func spec()
    {
        describe("formatting dates") {
            it("should print correct date") {

                var c = DateComponents()
                c.year = 2016
                c.month = 5
                c.day = 24
                c.hour = 4
                c.minute = 33
                c.second = 12

                let gregorian = NSCalendar(identifier: .gregorian)!
                let date = gregorian.date(from: c)!

                expect(DateFormatter.formatGmt(date)).to(equal("2016-05-24T04:33:12Z"))
            }
        }
    }
}
trubi
  • 295
  • 2
  • 14

3 Answers3

2

I use Quick + Nimble too. The code looks fine to me.

My guess is that the class is not being compiled. Can you go to Targets > AppTests > Build Phrases. Ensure that the DateFormatterTest is in Compile Sources.

Screenshot: enter image description here

Zac Kwan
  • 5,587
  • 4
  • 20
  • 27
0

I had this problem once. I can't remember exactly what I did to fix it, but one of the things I tried was:

Override the spec() method, and add super.spec() right on the beginning.

Bruno Pinheiro
  • 155
  • 1
  • 8
-4

A test class should include setUp() and tearDown(),and you should call the name of your function as testSpec().Named function use 'test' as beginning. you can try it.

Yangzhi
  • 3
  • 4