[BAEL-2998] - rearranging test order

This commit is contained in:
at508 2019-09-26 22:58:21 -04:00
parent bb71b1ec07
commit e25f50fa1b
2 changed files with 18 additions and 17 deletions

View File

@ -6,9 +6,7 @@ import java.util.Set;
import org.springframework.stereotype.Component;
import lombok.Getter;
import lombok.ToString;
@ToString
@Component
public class UserCache {

View File

@ -1,13 +1,16 @@
package com.baeldung.dirtiescontext;
import org.junit.FixMethodOrder;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
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.junit4.SpringJUnit4ClassRunner;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = SpringDataRestApplication.class)
class DirtiesContextIntegrationTest {
@ -15,27 +18,27 @@ class DirtiesContextIntegrationTest {
@Autowired
protected UserCache userCache;
@Test
void testA() {
userCache.addUser("Jane Doe");
userCache.printUserList("Test A");
}
@Test
void testB() {
userCache.printUserList("Test B");
}
@DirtiesContext(methodMode = MethodMode.AFTER_METHOD)
@Test
void testOne() {
void testC() {
userCache.addUser("John Doe");
userCache.printUserList("Test One");
userCache.printUserList("Test C");
}
@Test
void testTwo() {
userCache.printUserList("Test Two");
}
@Test
void testThree() {
userCache.addUser("Jane Doe");
userCache.printUserList("Test Three");
}
@Test
void testFour() {
userCache.printUserList("Test Four");
void testD() {
userCache.printUserList("Test D");
}
}