Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

NoSQLUnit Forge Plugin is Forged

DZone's Guide to

NoSQLUnit Forge Plugin is Forged

· Database Zone
Free Resource

Download the Guide to Open Source Database Selection: MySQL vs. MariaDB and see how the side-by-side comparison of must-have features will ease the journey. Brought to you in partnership with MariaDB.

 


NoSQLUnit is a JUnit extension to make writing unit and integration tests of systems that use NoSQL backend easier.

Forge is a core framework and next-generation shell for tooling and automation at a command line level.

With NoSQLUnit Forge Plugin we can use Forge to create tests for NoSQL databases using NoSQLUnit.

This plugin we can create three kind of tests depending on the lifecycle that is required:
  • Embedded: typically used in unit testing which starts an embedded instance of required database (not supported by all engines).
  • Managed: usually used during integration or high level tests, which starts a remote instance in the same computer where tests are run.
  • Remote: which uses already run database instances, usually in remote computers.
In current version of plugin, it supports next databases:
  • MongoDB
  • Neo4j
  • Redis
  • Cassandra
  • HBase
  • Infinispan
  • CouchDB
When we execute the main command of this plugin, one JUnit test configured with NoSQLUnit features and one dataset file will be created.
Moreover the created test will contain one method for each public method of development class under test.
The main command is nosqlunit. Then the lifecycle, which can be embedded, managed or remote. And finally depending on the chosen lifecycle some the arguments.
The common arguments are:
  • engine: we choose which database engine we want to use.
  • databaseName: we set the name of the database under test.
  • classname: we set the name of the test class created by the plugin.
  • classUnderTest: full class name of the class we want to write a test.
Embedded
There is no special arguments
Managed
  • path: home directory where NoSQL database is installed.
Remote
  • host: server address.
  • port: server port.
So for example a valid command will be:
nosqlunit managed --engine MONGODB --path /opt/mongo --databaseName test --classname MyTest --classUnderTest com.example.MyClass.java
And it creates MyTest test class under /src/test/java/com/example and a dataset file in /src/test/resources/com/example.
As almost all Forge plugins, you can install NoSQLUnit Forge Plugin by calling forge find-plugin nosqlunit and   forge install-plugin nosqlunit.
And finally remember that you can play with TAB to make your life easier.

Interested in reducing database costs by moving from Oracle Enterprise to open source subscription?  Read the total cost of ownership (TCO) analysis. Brought to you in partnership with MariaDB.

Topics:

Published at DZone with permission of Eric Genesky. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}