Search code examples
scalasbtamazon-dynamodbdynamo-local

How to start Amazon DynamoDB Local automatically in SBT tests?


I am trying to run a Scala test suite using Amazon DynamoDB Local via this plugin: https://github.com/localytics/sbt-dynamodb . It works, but only if I start DynamoDB Local manually on the command-line (sbt start-dynamodb-local). I would like it to start automatically whenever someone executes sbt test in the parent project directory. According to the docs:

To have DynamoDB Local automatically start and stop around your tests

startDynamoDBLocal := startDynamoDBLocal.dependsOn(compile in Test).value
test in Test := (test in Test).dependsOn(startDynamoDBLocal).value
testOptions in Test += dynamoDBLocalTestCleanup.value

but this just doesn't work:

com.amazonaws.SdkClientException: Unable to execute HTTP request: Connect to localhost:8000 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused

What am I doing wrong?


Solution

  • I managed to resolve it with the following:

    1. Move plugin reference addSbtPlugin("com.localytics" % "sbt-dynamodb" % "1.4.3") to the root project's project/plugins.sbt.
    2. Qualify compile with sbt.Keys.compile.