Description
Freezer is a library that allows your Swift tests to travel through time by mocking NSDate class.
Freezer alternatives and similar libraries
Based on the "Testing" category.
Alternatively, view Freezer alternatives based on common mentions on social networks and blogs.
-
OHHTTPStubs
Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers! -
Buildasaur
Automatic testing of your Pull Requests on GitHub and BitBucket using Xcode Server. Keep your team productive and safe. Get up and running in minutes. @buildasaur -
Erik
Erik is an headless browser based on WebKit. An headless browser allow to run functional tests, to access and manipulate webpages using javascript. -
AutoMockable
AutoMocker is a Swift framework that leverages the type system to let you easily create mocked instances of your data types. -
XCUITestHelper
XCUITestHelper helps you writing UI tests within SwiftUI. It provides a set of useful extensions on XCUIApplication, XCUIElement and XCUIElementQuery to make your tests more readable and easier to maintain.
InfluxDB high-performance time series database

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Freezer or a related project?
Popular Comparisons
README
Freezer
Freezer is a library that allows your Swift tests to travel through time by mocking NSDate
class.
Usage
Once Freezer.start()
has been invoked, all calls to NSDate()
or NSDate(timeIntervalSinceNow: secs)
will return the time that has been frozen.
Helper function
freeze(NSDate(timeIntervalSince1970: 946684800)) {
print(NSDate()) // 2000-01-01 00:00:00 +0000
}
Raw usage
let freezer = Freezer(to: NSDate(timeIntervalSince1970: 946684800))
freezer.start()
print(NSDate()) // 2000-01-01 00:00:00 +0000
freezer.stop()
Time shifting
Freezer will move you to a specified point in time, but then the time will keep ticking.
timeshift(NSDate(timeIntervalSince1970: 946684800)) {
print(NSDate()) // 2000-01-01 00:00:00 +0000
sleep(2)
print(NSDate()) // 2000-01-01 00:00:02 +0000
}
Nested calls
Freezer allows performing nested freezing/shifts
freeze(NSDate(timeIntervalSince1970: 946684800)) {
freeze(NSDate(timeIntervalSince1970: 946684000)) {
freeze(NSDate(timeIntervalSince1970: 946684800)) {
print(NSDate()) // 2000-01-01 00:00:00 +0000
}
print(NSDate()) // 1999-12-31 23:46:40 +0000
}
print(NSDate()) // 2000-01-01 00:00:00 +0000
}
Installation
CocoaPods
Just add pod 'Freezer', '~> 1.0'
to your test target in Podfile
.
Carthage
There is no Xcode project, so Carthage will not build a framework for this library. You can still use it, just add github "Pr0Ger/Freezer" ~> 1.0
to your Cartfile
and then add Carthage/Checkout/Freezer/freezer.swift
to your test target.
Manual
Just copy freezer.swift to your Xcode project and add it to your tests target. Most likely this library will not be updated, unless Apple breaks something by changing an internal implementation of NSDate
, so this way is good too.
License
MIT
*Note that all licence references and agreements mentioned in the Freezer README section above
are relevant to that project's source code only.