scalatest-embedded-redis


License

License

MIT
Categories

Categories

Scala Languages Redis Data Databases
GroupId

GroupId

com.github.sebruck
ArtifactId

ArtifactId

scalatest-embedded-redis_2.11
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

scalatest-embedded-redis
scalatest-embedded-redis
Project URL

Project URL

https://github.com/Sebruck/scalatest-embedded-redis/
Project Organization

Project Organization

com.github.sebruck
Source Code Management

Source Code Management

https://github.com/Sebruck/scalatest-embedded-redis/

Download scalatest-embedded-redis_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.sebruck/scalatest-embedded-redis_2.11/ -->
<dependency>
    <groupId>com.github.sebruck</groupId>
    <artifactId>scalatest-embedded-redis_2.11</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.sebruck/scalatest-embedded-redis_2.11/
implementation 'com.github.sebruck:scalatest-embedded-redis_2.11:0.2.0'
// https://jarcasting.com/artifacts/com.github.sebruck/scalatest-embedded-redis_2.11/
implementation ("com.github.sebruck:scalatest-embedded-redis_2.11:0.2.0")
'com.github.sebruck:scalatest-embedded-redis_2.11:jar:0.2.0'
<dependency org="com.github.sebruck" name="scalatest-embedded-redis_2.11" rev="0.2.0">
  <artifact name="scalatest-embedded-redis_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.sebruck', module='scalatest-embedded-redis_2.11', version='0.2.0')
)
libraryDependencies += "com.github.sebruck" % "scalatest-embedded-redis_2.11" % "0.2.0"
[com.github.sebruck/scalatest-embedded-redis_2.11 "0.2.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.11
com.github.kstyrc : embedded-redis jar 0.6

test (3)

Group / Artifact Type Version
com.github.etaty : rediscala_2.11 jar 1.8.0
org.scalatest : scalatest_2.11 jar 3.0.3
com.typesafe.akka : akka-actor_2.11 jar 2.5.4

Project Modules

There are no modules declared in this project.

scalatest-embedded-redis

With this project you can easily use an embedded redis in your unit tests.

It is inspired from scalatest-embedmongo.

Usage

Getting started

Add the following to your build.sbt file.

libraryDependencies += "com.github.sebruck" %% "scalatest-embedded-redis" % "0.4.0"

For a working example have a look at the tests.

One redis instance per test for synchronous suites

import com.github.sebruck.EmbeddedRedis
import org.scalatest.FunSuite

class MyTest extends FunSuite with EmbeddedRedis {

  test("something with redis") {
    withRedis() { port =>
      // ...
      succeed
    }
  }
}

One redis instance per test for asynchronous suites

import com.github.sebruck.EmbeddedRedis
import org.scalatest.AsyncFunSuite

import scala.concurrent.Future

class MyTest extends AsyncFunSuite with EmbeddedRedis {

  test("something with redis") {
    withRedisAsync() { port =>
      // ...
      Future.successful(succeed)
    }
  }
} 

One redis instance per suite

import com.github.sebruck.EmbeddedRedis
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import redis.embedded.RedisServer

class MyTest extends FunSuite with EmbeddedRedis with BeforeAndAfterAll {

  var redis: RedisServer = null
  var redisPort: Int = null

  override def beforeAll() = {
    redis = startRedis() // A random free port is chosen
    redisPort = redis.ports().get(0)
  }

  test("something with redis") {
    // ...
  }

  override def afterAll() = {
    stopRedis(redis)
  }
}

Versions

Version
0.2.0