[Engine-devel] Better testing for ValidationResults using ValidationResultMatchers

Mike Kolesnik mkolesni at redhat.com
Sun Mar 17 09:30:35 UTC 2013


Hi, 

If you don't know what ValidationResult is, check out http://www.ovirt.org/ValidationResult 

In a gist, I added a new way to test this using JUnit's assertThat syntax: 
// Test that validation result is valid
assertThat(someValidation(), isValid());

// Test that validation result is invalid
assertThat(someValidation(), failsWith(VdcBllMessages.SOME_ERROR));

// Test that validation result is invalid and has replacement
assertThat(someValidation(), both(failsWith(VdcBllMessages.SOME_ERROR)).and(replacements(hasItem(EXPECTED_REPLACEMENT)))); You need to statically import ValidationResultMatchers (and the basic JUnit matchers) for this to work. 

The rest I documented in the aforementioned wiki. 

Check out the patch: http://gerrit.ovirt.org/#/c/13061 

Or how to use it: http://gerrit.ovirt.org/#/c/13062 


Regards, 
Mike 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/engine-devel/attachments/20130317/1ace4b73/attachment.html>


More information about the Engine-devel mailing list