title: Run code only on test
body: <p>I would like to execute a method only on test running.</p>
  
  <p>This is a completion of integration test. When I run integration test, I want to generate a json file with the state of an Object. </p>
  
  <p>I think of doing something like this in my code : </p>
  
  <pre><code>if(environnement == TEST) {
     // save object as json
  }
  </code></pre>
  
  <p>Do you know other method to do this ? less crapy ?</p>
  
  <p>Regards</p>