Giter VIP home page Giter VIP logo

scalatest-embedmongo's Introduction

SCALATEST EMBED MONGO

This project provides API to use an embedMongo database in your Scala tests

It is directly inspired by spec2-embedmongo project.

This works in a Java 6+ environment

Roadmap

  • trait to use embedMongo OK (0.1 version)
  • trait to use embedMongo fixture OK (0.1 version)
  • deploy on maven central OK (0.1 version)
  • build on scala 2.10 OK (0.2 version)
  • cross compilation 2.9 & 2.10 OK (0.2 version)
  • manage port uses for parallel testing TODO

Installation

Git repo

scalatest-embedmongo is a SBT project.
It use 0.12 sbt version.

Maven dependency


    <dependency>
        <groupId>com.github.simplyscala</groupId>
        <artifactId>scalatest-embedmongo_2.10</artifactId>
        <version>0.2.1</version>
        <scope>test</scope>
    </dependency>

SBT dependency


    libraryDependencies += "com.github.simplyscala" %% "scalatest-embedmongo" % "0.2.1" % "test"
Only the following Scala versions 2.9.1, 2.9.2 & 2.10 are currently supported.

Play! specific dependency management

In your play! project Build file :


    object ApplicationBuild extends Build {

        val appDependencies = Seq (
            "com.github.simplyscala" %% "scalatest-embedmongo" % "0.2.1" % "test"
        )
    }

Simple JAR file

0.2.1 jar version

Usage

In order to use scalatest-embedmongo API, your test must extends MongoEmbedDatabase as follows:


    import com.github.simplyscala.MongoEmbedDatabase

    ...

    MyTest extends FunSuite with MongoEmbedDatabase

Basic Usage (mutable way)


    MyTest extends FunSuite with MongoEmbedDatabase with BeforeAndAfter {

        var mongoProps: MongodProps = null

        before {
            mongoProps = mongoStart()   // by default port = 12345 & version = Version.2.3.0
        }                               // add your own port & version parameters in mongoStart method if you need it

        after { mongoStop(mongoProps) }

        test("some test with mongo") {
            ...
        }
    }

Immutable way usage

You can use fixture to start/stop the embed server with immutable way :


    MyTest extends FunSuite with MongoEmbedDatabase {

        test("test with fixture") {
            //add your own port & version parameters in withEmbedMongoFixture method if you need it
            withEmbedMongoFixture() { mongodProps =>
                // do some mongo database operations
                // in this fixture the dabatase is started
                // at the end of this fixture the database is stopped
            }
        }
    }

Be careful if you launch yours tests in parallel you could have some trouble because of mongodb port multiples uses !

footpage

This file is written with .textile extension

Maven Repository Usage Guide
Sonatype project JIRA Page

scalatest-embedmongo's People

Contributors

ubourdon avatar manub avatar 0xroch avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.