5. Example View
class ArticleTableViewCell: UITableViewCell {
@IBOutlet var dateLabel: UILabel!
@IBOutlet var titleLabel: UILabel!
@IBOutlet var sourceLabel: UILabel!
@IBOutlet var articleImageView: UIImageView!
}
33. Property Based Testing
!// Generate random inputs
for all (x, y, …)
!// Keep generating inputs while this is false
such that precondition(x, y, …)
!// Test the property
property(x, y, …) is true
34. Property Based Testing (Example)
!// Generate random inputs
for all (numbers: [Int])
!// Keep generating inputs while this is false
such that alwaysTrue(numbers)
!// Test the property
numbers.sort() is sorted
!!<=> numbers[n] !<= numbers[n + 1]
35. Back to UIView Testing
!// Generate random view models
for all (viewModel: ArticleViewModel)
view.configure(with: viewModel)
!// Test the property
view.snapshot is matching
!&& view.layout is valid