Last active
August 29, 2015 14:02
-
-
Save spikeheap/2e3f371615deb276f46e to your computer and use it in GitHub Desktop.
Simple introspection to dig into model inequality in Spock tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def expected | |
| def actual | |
| def propertiesToCompare = expected.class.declaredFields.findAll { !(it.name =~ /^__/ || it.name =~ /^\$/ || it.name == "metaClass") } | |
| // For each property prints [equality] : [property name] -> [expected value] -|- [actual value] | |
| propertiesToCompare.each { property -> | |
| println "${expected[property.name] == actual[property.name]} : ${property} -> ${expected[property.name]} -|exp: ${actual[property.name]} " | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment