title: Using JUnit @ResourceLock to execute some test classes sequentially
body: <p>I've got a large integration tests suite, test classes are executed in parallel and class methods are executed sequentially. There are 2 test classes which use the same service for creating/reading/removing entities, and sharing this service creates a race condition:</p>
  
  <ol>
  <li>Class Foo is creating a record</li>
  <li>Class Bar is removing all records</li>
  <li>Class Foo is trying to read the created record asserting that it exists, but at this point it's been removed by Bar.</li>
  </ol>
  
  <p>I tried annotating both classes with JUnit's <code>@ResourceLock</code> but it didn't work, maybe I'm missing something?</p>
  
  <p>Example:</p>
  
  <pre><code>@ResourceLock("serivceResource")
  class Foo {
  @Test
  void fooTest(){
  //create a record
  //read the created record
  //assert record created
  }
  }
  
  
  
  @ResourceLock("serivceResource")
  class Bar {
  @Test
  void barTest(){
  //wipe all records
  }
  }
  </code></pre>
  
  <p><code>Foo#fooTest</code> and <code>Bar#barTest</code> are in race condition dispute the use of <code>@ResourceLock</code>.</p>
  
  <p>I wonder maybe I need to configure JUnit somehow for it to work?</p>