Core Data Basics: Testing

Yeah, testing is important

Steven Curtis
6 min readOct 8, 2020
Photo by Andriyko Podilnyk on Unsplash

Prerequisites:

  • You will be expected to be aware how to make a Single View Application in Swift
  • You’ll need to know about the basics of Core Data
  • You’ll find this easier if you know something about Dependency Injection and Protocols, but of course you can read on and find how they are used in this project
  • This article does use a custom alertview, but if you want a full guide to that I’ve written just that here.

Terminology

Core Data: A framework that allows you to manage the model layer objects in your application. Core Data does this by being an object graph management and persistence framework.

Why test

You should be testing! Right? TDD has gone from something reserved for the cool kids to something that you should be doing in your personal projects (I wonder if I’ll get comments from the Wrong Brigade about this? It’s a pity comment, person I’m imagining)

By storing Core Data files there are difficulties in isolating the database from the tests. Each test should be repeatable and it would be quite heavyweight to delete the whole database after every test.

The example App

--

--

No responses yet