Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think that you can use any testing framework you like.</p> <p>The thing is that you have to execute user actions in one test method asynchronously an synchronize them at some point.</p> <p>The approach I would recommend you is it to use <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ExecutorService.html" rel="nofollow">ExecutorService</a> framework from <code>java.util.concurrent</code> package.</p> <p>So first of all you have to create the executor</p> <pre><code>ExecutorService executorService = Executors.newFixedThreadPool(2); </code></pre> <p>Next use executor to asynchronously run tasks using <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ExecutorService.html#submit%28java.lang.Runnable%29" rel="nofollow">submit</a> method and synchronize actions using <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/Future.html#get%28%29" rel="nofollow">get</a> method.</p> <p>See code example below</p> <pre><code>@Test public void test() throws Exception { final User firstUser = new User(); Future&lt;?&gt; firstUserAction = executorService.submit(new Runnable() { @Override public void run() { firstUser.doSomething(); firstUser.doSomethingElse(); } }); final User secondUser = new User(); Future&lt;?&gt; secondUserAction = executorService.submit(new Runnable() { @Override public void run() { secondUser.doSomething(); } }); // synchronization firstUserAction.get(); secondUserAction.get(); // synchronized now secondUserAction = executorService.submit(new Runnable() { @Override public void run() { secondUser.doSomethingElse(); } }); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload