From e6476985917239660d2a9e8be3ae5c77e0416df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Wed, 23 Dec 2020 14:06:02 +0100 Subject: [PATCH] Fix problem with admin test - cleaning database MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../test/java/com/plannaplan/services/UserServiceTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/buisnesslogic/src/test/java/com/plannaplan/services/UserServiceTest.java b/buisnesslogic/src/test/java/com/plannaplan/services/UserServiceTest.java index 9e6cd45..955e497 100755 --- a/buisnesslogic/src/test/java/com/plannaplan/services/UserServiceTest.java +++ b/buisnesslogic/src/test/java/com/plannaplan/services/UserServiceTest.java @@ -2,6 +2,8 @@ package com.plannaplan.services; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.MethodMode; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -108,10 +110,9 @@ public class UserServiceTest { assertTrue(userService.adminExists()); } + @Test - /** - * In future can fail the test due to create a admin user in the another tests. - */ + @DirtiesContext(methodMode = MethodMode.BEFORE_METHOD) public void shouldReturnNotAdminExists() { final String email = "shouldReturnNotAdminExists@UserService.test"; this.userService.save(new User("StudentTom", "Smieszny", email, UserRoles.STUDENT));