Skip to content

Commit

Permalink
clean up after tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesquires committed Jun 6, 2016
1 parent 4af88f3 commit f6d6251
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Tests/MigrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class MigrationTests: TestCase {
_ = try? model.removeExistingStore()
}

override func tearDown() {
_ = try? model.removeExistingStore()
super.tearDown()
}

func test_ThatCoreDataModel_NeedsMigration_WhenUsingOldModel() {
// GIVEN: an existing SQLite file with metadata pointing to an old version of the model
createSQLitePersistentStore(managedObjectModel: managedObjectModel(versionName: "Version 1"))
Expand Down
8 changes: 6 additions & 2 deletions Tests/StackFactoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ import JSQCoreDataKit
class StackFactoryTests: TestCase {

override func setUp() {
let model = CoreDataModel(name: modelName, bundle: modelBundle)
_ = try? model.removeExistingStore()
cleanUp()
super.setUp()
}

override func tearDown() {
cleanUp()
super.tearDown()
}

func test_ThatStackFactory_InitializesSuccessFully() {
let factory = CoreDataStackFactory(model: inMemoryModel)
XCTAssertEqual(factory.model, inMemoryModel)
Expand Down
6 changes: 6 additions & 0 deletions Tests/StackTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ import JSQCoreDataKit

class StackTests: XCTestCase {

override func tearDown() {
let model = CoreDataModel(name: modelName, bundle: modelBundle)
_ = try? model.removeExistingStore()
super.tearDown()
}

func test_ThatSQLiteStack_InitializesSuccessfully() {
// GIVEN: a SQLite model
let sqliteModel = CoreDataModel(name: modelName, bundle: modelBundle)
Expand Down
8 changes: 8 additions & 0 deletions Tests/TestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ extension CoreDataStackFactory {
}


extension XCTestCase {
func cleanUp() {
let model = CoreDataModel(name: modelName, bundle: modelBundle)
_ = try? model.removeExistingStore()
}
}


class TestCase: XCTestCase {

let inMemoryModel = CoreDataModel(name: modelName, bundle: modelBundle, storeType: .inMemory)
Expand Down

0 comments on commit f6d6251

Please sign in to comment.