I run my Integration Test cases with Spring Boot with the help of my local Redis server on my machine.
But I want an embedded Redis server which is not dependent on any
You can use ozimov/embedded-redis as a Maven(-test)-dependency (this is the successor of kstyrc/embedded-redis).
Add the dependency to your pom.xml
...
it.ozimov
embedded-redis
0.7.1
test
Adjust your application properties for your integration test
spring.redis.host=localhost
spring.redis.port=6379
Use the embedded redis server in a test configuration
@TestConfiguration
public static class EmbededRedisTestConfiguration {
private final redis.embedded.RedisServer redisServer;
public EmbededRedisTestConfiguration(@Value("${spring.redis.port}") final int redisPort) throws IOException {
this.redisServer = new redis.embedded.RedisServer(redisPort);
}
@PostConstruct
public void startRedis() {
this.redisServer.start();
}
@PreDestroy
public void stopRedis() {
this.redisServer.stop();
}
}