TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
AIVerification is a testing library for verifying user inputs.
platform :ios, '7.0'
pod 'AIVerification', git: 'https://github.com/WideEyeLabs/AIVerification.git'
To get started simply import the AIVerification header (AIVerification.h). Verifications are simple human readable assertions that test the state of subclasses of UIView. After it has run, a VerificationTest generates error messages for each of the assertions that failed which can then be displayed to the user. The following is an example test with a single assertion...
NSArray *errors = [VerificationTest forInputs:inputViews
andTestCases:^(VerificationTest *inspect) {
[inspect.textField[@"Name"] verifyItIsNotEmpty];
}];
// Full example below
If the assertion in this test fails, the errors array will be populated with the error string "The Name field must not be empty". Error messages can be customized by calling verification methods that also take an NSString error as an argument (e.g., verifiyItIsNotEmptyWithError:(NSString)).
Because it is a framework that tests by inspecting objects instead of using subclassing, AIVerification plays well with any UIView subclasses you may want to include in your project (try JVFloatLabeledTextField).
Of course you need more information to determine if this will be useful to you. Here are some points about AIVerification to consider.
#import <AIVerification.h>
// ..
// ..
NSDictionary *inputViews = @{ @"Name" : _nameField,
@"Password" : _passwordField,
@"Confirmation" : _confirmationField };
NSString *passwordText = self.passwordField.text;
NSArray *errors = [VerificationTest forInputs:inputViews
andTestCases:^(VerificationTest *inspect) {
[inspect.textField[@"Name"] verifyItIsNotEmpty];
[inspect.textField[@"Password"] verifyItIsLongerThan:@6];
[inspect.textField[@"Confirmation"] verifyItMatches:passwordText
withDescription:@"Password Field"];
}];
if ([errors count] != 0)
{
// handle errors
NSString *errorMessage = [errors componentsJoinedByString:@"\n\n"];
}
else
{
// proceed
}