title: Create simple Junit @rule
body: <p>I've just discovered JUnit Rules. </p>
  
  <p>I have a Groovy unit test case as follows...</p>
  
  <pre><code>class CheckRegistrationValidatorTest {
  
      @Test
      void 'input validation'() { 
          def checkRegistrationValidator = 
                 new CheckRegistrationValidator(regexCarTruckRegNo:/^[a-zA-Z0-9]{1,6}$/, regexMotorcycleRegNo:/^[a-zA-Z0-9]{3,5}$/, regexTrailorRegNo:/^[a-zA-Z0-9]{6}$/, regexBoatRegNo:/^[a-zA-Z0-9]{1,6}$/, regexVin:/^(?=.*[0-9])(?=.*[a-zA-Z])([a-hj-npr-z0-9]{17})$/, regexChassis:/^[a-zA-Z0-9]{1,6}$/)
          def input = [
                  vehicleClassCode: '0',
                  vehicleIdentificationType: 'registrationNumber',
                  vehicleRegistrationNumber: 'WEB001'
              ]   
          checkRegistrationValidator.validate input
      }
  
  }
  </code></pre>
  
  <p>I want to replace the checkRegistrationValidator instantiation with an @ClassRule. I've attempted to read up on them but I'm just not getting it.</p>
  
  <p>Can someone help me with how to create a @ClassRule just to do that line of code.</p>
  
  <p>thanks</p>