Skip to content

Instantly share code, notes, and snippets.

@ringoluo
Created February 10, 2015 15:58
Show Gist options
  • Save ringoluo/250762e7630ae0883c57 to your computer and use it in GitHub Desktop.
Save ringoluo/250762e7630ae0883c57 to your computer and use it in GitHub Desktop.
nosqlunit cookbook

Unit Testing FIRST Rules

  • Fast: no network/filesystem access
  • Isolated: independent of other tests
  • Repeatable: system has known state
  • Self-Validated:
  • Timely:

NoSqlUnit

  • modes:
    • in-memory mode: unit testing
    • managed mode: integration testing
    • remote: manage connection by developer
  • rules: maintain database in known state
  • annotations
    • @UsingDataSet: seed database with defined dataset
      • strategy
        • INSERT
        • DELETE_ALL
        • CLEAN_INSERT
        • REFRESH
      • @UsingDataSet(locations="my_data_set.json", loadStrategy=LoadStrategyEnum.REFRESH)
    • @ShouldMatchDataSet: verify database
      • @ShouldMatchDataSet(location="my_expected_data_set.json")

MongoDB

  • Lifecycle Management Rules

    • InMemoryMongoDb
      • implementation with Fongo
      • date: { "$date" : "2011-01-05T10:09:15.210Z" }
      • objectid: {"$oid": "xxxx"}
      • @ClassRule public static InMemoryMongoDb inMemoryMongoDb = newInMemoryMongoDbRule().build();
    • ManagedMongoDb
      • default installtion from MONGO_HOME
      • target path target/mong-temp
      • db parth {target path}/mongo-dbpath
      • @ClassRule public static ManagedMongoDb managedMongoDb = newManagedMongoDbRule().build();
  • Replica setup

  • Sharding setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment