How to reset between tests
<p>I have a test class </p>

<pre><code>@RunWith(SpringRunner.class)
@DataJpaTest
</code></pre>

<p>I have two tests. In every test I do the same operation, persist the object. Only the find call are different.</p>

<p>If I run both tests together they fail but if I run test one after another they are successful.</p>

<p>There is no reset between each test. How to do that? Only the call to the repository is different in each test. </p>

<pre><code>@Test
public void findTopByCommerceCommerceIdOrderByEntryTimeDesc() {

    Long commerceId = 1L;

    Commerce commerce = new Commerce();
    commerce.setName("test");
    this.entityManager.persist(commerce);

    Member member = new Member();
    member.setCommerce(commerce);
    member.setMan(true);
    member.setName("bob binette");

    this.entityManager.persist(member);

    Visit visit1 = new Visit();
    visit1.setCommerce(commerce);

    visit1.setMember(member);
    visit1.setEntryTime(LocalDateTime.of(LocalDate.now(), LocalTime.now()));

    Visit visit2 = new Visit();
    visit2.setCommerce(commerce);

    visit2.setMember(member);
    visit2.setEntryTime(LocalDateTime.of(LocalDate.now().minusDays(2), LocalTime.now()));

    this.entityManager.persist(visit1);
    this.entityManager.persist(visit2);

    Visit visit = visitRepository.findTopByCommerceCommerceIdOrderByEntryTimeDesc(commerceId);

    assertEquals(visit.getVisitId(), Long.valueOf("1"));

}
</code></pre>

<p>Edit</p>

<p>i put all the code : <a href="http://pastebin.com/M9w9hEYQ" rel="noreferrer">http://pastebin.com/M9w9hEYQ</a></p>