lundi 27 juillet 2015

Swift - Model unit testing with ObjectMapper

I have a bunch of models using the ObjectMapper library (as I'm parsing JSON to build the objects).
How can I write unit tests for my models? I'm fairly new to this and have been pretty confused by what I've read so far.

Here's an example of one of my models:

import ObjectMapper

class User: Mappable {
    var id: Int?
    var firstName: String?
    var lastName: String?

    required init?(_ map: Map) {
        mapping(map)
    }

    func mapping(map: Map) {
        id        <- map["ID"]
        firstName <- map["first_name"]
        lastName  <- map["last_name"]
    }
}

Aucun commentaire:

Enregistrer un commentaire