AIVerification 1.0.0

AIVerification 1.0.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total283
Week0
Month0

Installs

Apps4
powered by Segment

GitHub

Stars4
Watchers2
Forks1
Issues0
Contributors1
Pull Requests0

Code

Files15
LOCLines of Code 260


  • By
  • Brian Thomas

AIVerification is a testing library for verifying user inputs.

In Your Podfile

platform :ios, '7.0'
pod 'AIVerification', git: 'https://github.com/WideEyeLabs/AIVerification.git'

About AIVerification

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).

"Is This For Me?"

Of course you need more information to determine if this will be useful to you. Here are some points about AIVerification to consider.

  • There are no callbacks to support continuous testing on changes to inputs (try TSValidatedTextField)
  • Verification assertions, such as 'verifyItIsNotEmpty', are only meangingful when called from within a test block (they currently have a void return).
  • The set of verification assertions is currently very limited. However, adding new ones is a fairly simple task.

Full Example

#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
}