Embracing the Messiness in Search of Epic Solutions

Tag: Spock

  • Guava: Testing equals(..) and hashcode(..)

    PROBLEM Let’s assume we want to test the following equals(..):- A correctly implemented equals(..) must be reflexive, symmetric, transitive, consistent and handles null comparison. In another word, you have to write test cases to pass at least these 5 rules. Anything less is pure bullshit. SOLUTION You can write these tests yourself… or you can… Read More…

  • Spock: Reading Test Data from CSV File

    Following up on my recent post about creating a Spock specification to read the test data from a CSV file without loading all the data into the memory, I created a CSVReader that implements Iterable that allows me to pull this off. You may download the source code here. With this implementation, I can now… Read More…

  • Maven: Unable to Execute Spock Specs

    PROBLEM When running mvn clean test, Maven Surefire Plugin doesn’t pick up *Spec.groovy test files. SOLUTION By default, Maven Surefire Plugin is configured to execute test files with the following patterns: **/Test*.java, **/*Test.java and **/*TestCase.java. To fix this, we need to modify the inclusion list for this plugin. Since both Java and Groovy files get… Read More…