I wonder if there is a need to create a Unit Test Case class or even a separate unit test method to test a Model of it is a Struct?
I trying to follow the TDD to create a Signup feature for my mobile app. On a piece of paper, I have sketched what I need to create:
- ViewController class,
- Presenter class,
- A Validator class to validate Model field values like the email address format and the password length and etc...
- WebService class to send HTTP Request with user details,
- A Signup Form Request Model struct. A Model struct that will be sent over to my server.
- A Signup Response Model struct. A Struct that will be used to convert server response into a Swift struct.
I wonder if there is a need to create a Unit Test Case class or even a separate unit test method to test a Model of it is a Struct? Structs do not have failable initializers. And because Swift struct has a memberwise initializer, there is really nothing to test...
For example. The SignupModel.swift - a separate file:
struct SignupModel {
let firstName: String
let lastName: String
let email: String
let password: String
}
Do I really need to create a test method:
func testInit_SignupModelExists() {
let signupModel = SignupModel(firstName:"John", lastName: "Doe", email: "[email protected]", password: "12345678")
XCTAssertNotNil(signupModel)
}
Do you guys create this kind of Unit tests when following the TDD?