Create Unit Tests for Memory Leaks in Swift.
Quick and Nimble is a Unit Testing framework that allows you to write tests in a more humanly readable fashion.
Release Version: 0.1.8
SpecLeaks is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SpecLeaks'
The example project contains a few Unit Tests that will let you understand how to use SpecLeaks.
To run the example project, clone the repo, and run pod install
from the Example directory first.
Command+U to run the sample tests.
Follow this guideline and to your Cartfile:
github "leandromperez/specleaks"
Note: don't forget to modify the framework search path from your testing target to include the folder that contains the compiled .framework files
In Xcode choose File | Swift Packages | Add package dependency and enter https://github.com/leandromperez/specleaks.
There is a folder in the repo Carthage-Example that contains a project called Carthage-Tests configured to use Carthage.
it("action")
blockLeakTest
passing a block that returns the object you want to testtoNot(leak())
or toNot(leakWhen())
class SomeObject {}
class SomeOjectTests: QuickSpec {
override func spec() {
describe("SomeObject") {
describe("init") {
it("must not leak"){
let someObject = LeakTest{
return SomeObject()
}
expect(someObject).toNot(leak())
}
}
}
}
}
class SomeViewController : UIViewController {}
class SomeViewControllerTests: QuickSpec {
override func spec() {
describe("SomeViewController"){
describe("viewDidLoad") {
let vc = LeakTest{
return SomeViewController()
}
it("must not leak"){
expect(vc).toNot(leak())
}
}
}
}
}
class SomeObject{
func doSomething(){
}
}
class SomeOjectTests: QuickSpec {
override func spec() {
describe("SomeObject") {
describe("doSomething") {
it("must not leak"){
let someObject = LeakTest{
return SomeObject()
}
let doSomethingIsCalled : (SomeObject) -> () = {obj in
obj.doSomething()
}
expect(someObject).toNot(leakWhen(doSomethingIsCalled))
}
}
}
}
}
SpecLeaks is available under the MIT license. See the LICENSE file for more info.
link |
Stars: 189 |
Last commit: 2 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics