Quick is a popular unit testing framework for Swift and Objective-C. Together with the matcher framework Nimble, it makes unit testing easier than XCTest. In the first tutorial, we will introduce basic knowledges about Quick with examples.
We can get the details about installation from the Installing Quick. Using CocoaPods is our favorite and recommendation.
Add test target for Xcode project
- if you start a new project
- if you have a project already
A basic Quick testing file is like
“QuickSpec is a base class all specs written in Quick inherit from.”
- From Quick Documentation
QuickSpec is subclass of XCTestCase which makes it found and driven by XCTest’s mechanism. We need to inherit QuickSpec and override the only function spec() where we put all our test case in. We’ll explain details in coming articles.
Like setUp() in XCTestCase, beforeEach is a closure which will be run before each test. We can put all the preparation codes in it
Like tearDown in XCTestCase, afterEach is a closure which will be run after each test. We can put all the cleaning codes in it
It, Context, Describe
To get a complete view of test in Quick, we will show an sample first.
Before introducing the core definitions, we need to explain Example definition in Quick. Example in Quick is test in XCTest, or test case in software testing. In codes, it is an ‘it’ function in which are the assertions to verify the behaviors of the our great app. So the ‘it’ function defines an example.
An ‘Example group’ is a logical group of examples. It is defined by context or describe. We can use context to test different scenario and group multiple scenarios into a describe.