title: Easier DynamoDB local testing
body: <p>I'm using <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.html" rel="noreferrer">DynamoDB local</a> for unit testing. It's not bad, but has some drawbacks. Specifically:</p>
  
  <ul>
  <li>You have to somehow start the server before your tests run</li>
  <li>The server isn't started and stopped before each test so tests become inter-dependent unless you add code to delete all tables, etc. after each test</li>
  <li>All developers need to have it installed</li>
  </ul>
  
  <p>What I want to do is something like put the DynamoDB local jar, and the other jars upon which it depends, in my <code>test/resources</code> directory (I'm writing in Java). Then before each test I'd start it up, running with <code>-inMemory</code>, and after the test I'd stop it. That way anyone pulling down the git repo gets a copy of everything they need to run the tests and each test is independent of the others.</p>
  
  <p>I have found a way to make this work, but it's ugly, so I'm looking for alternatives. The solution I have is to put a .zip file of the DynamoDB local stuff in <code>test/resources</code>, then in the <code>@Before</code> method, I'd extract it to some temporary directory and start a new java process to execute it. That works, but it's ugly and has some drawbacks:</p>
  
  <ul>
  <li>Everyone needs the java executable on their <code>$PATH</code></li>
  <li>I have to unpack a zip to the local disk. Using local disk is often dicey for testing, especially with continuous builds and such.</li>
  <li>I have to spawn a process and wait for it to start for each unit test, and then kill that process after each test. Besides being slow, the potential for left-over processes seems ugly.</li>
  </ul>
  
  <p>It seems like there should be an easier way. DynamoDB Local is, after all, just Java code. Can't I somehow ask the JVM to fork itself and look inside the resources to build a classpath? Or, even better, can't I just call the <code>main</code> method of DynamoDB Local from some other thread so this all happens in a single process? Any ideas?</p>
  
  <p>PS: I am aware of Alternator, but it appears to have other drawbacks so I'm inclined to stick with Amazon's supported solution if I can make it work.</p>