Unit testing allows testing individual units of code in isolation using Spock, a testing framework for Java and Groovy. Spock specifications extend Specification and contain fixture methods like setup() and feature methods to define test cases and expected behavior. Feature methods use blocks like when, then, and expect to define stimuli and verify outputs. Spock supports data-driven testing using a data table and mocking dependencies using Mock() to focus testing on the unit. Basic Spock commands include running tests with grails test-app and viewing test reports.