7bb2dd11
YunaiV
引入 redis mock 服务器
|
1
2
3
4
5
6
7
8
9
10
11
|
package cn.iocoder.dashboard;
import org.junit.jupiter.api.AfterEach;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.jdbc.Sql;
import javax.annotation.Resource;
|
92997a0c
YunaiV
开始编写 SysAuthServi...
|
12
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
|
7bb2dd11
YunaiV
引入 redis mock 服务器
|
13
14
|
@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) // 每个单元测试结束后,清理 DB
|
ac17cf18
YunaiV
优化单元测试,新增 BaseDbU...
|
15
|
@Deprecated
|
7bb2dd11
YunaiV
引入 redis mock 服务器
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
public class BaseSpringBootUnitTest {
@Resource
private StringRedisTemplate stringRedisTemplate;
/**
* 每个单元测试结束后,清理 Redis
*/
@AfterEach
public void cleanRedis() {
stringRedisTemplate.execute((RedisCallback<Object>) connection -> {
connection.flushDb();
return null;
});
}
}
|