Since your property is declared using IBOutlet
, I assume you're using storyboards for your views. If this is the case, then it's not an issue of the textField's text being nil, it's an issue of the whole textField being nil.
When a view controller is loaded from the storyboard, all your IBOutlets (provided they're hooked up correctly), are initialized for you. When running unit tests, there is no interaction with the storyboard, so your textField will not be initialized.
To get around this issue, you can create and assign the textField yourself:
SignUpViewController *viewController = [[SignUpViewController alloc]init];
viewController.username = [[UITextField alloc] init];
viewController.username.text = @"username@example.com";
Or, even better, you could take a look at OCMock, and create and assign a mock text field in your unit tests.