Git Product home page Git Product logo

dbunittester's Introduction

DbUnitTester Database Unit Test Execution Tool
==============================================

Copyright (c) 2012 Ivan Georgiev.

All rights reserved.

Prerequisites
-------------

Bul7Lib - available as separate jar download.

Getting Started
---------------

1. Installation

You need to download following packages:

DbUnitTester.jar
lib/Bul7Lib.jar

Make sure you place them in the directories denoted above.

2. Prepare Test Definition.

The definition for tests is stored in json file.

In this exacmple we are creating unit tests for database procedure that loads
the PERSONS table.

---------------- persons.ut.json -------------------

{
	"executor": {
		"type": "SqlDump",
	},
	"testcase": {
		name: "MyETLStaging",
		"testcases": [
			{
				name: "PersonsStaging",
				"sources": [
					{ "name": "expect", "source": "fix_persons"},
					{ "name": "actual", "source": "persons", "filter": "person_id = 32" }
				],
				"validators": [
					{
						"name": "CountMatch",
						"type": "CountMatch",
						"expect": "expect",
						"actual": "actual"
					},
					{
						"name": "DataMatch",
						"type": "ColByColDataMatch",
						"expect": "expect",
						"actual": "actual",
						"columns": "person_id,first_name,last_name",
					}
				]
			}
		]
	}
}

----------------------------------------------------

4. Dump interpreted definition

Modify the persons.ut.java file. Modify the "executor" definition:

   "type": "Dump"

Execute following command:
   java -jar DbUnitTester.jar persons.ut.json

This will display the test definiton loaded by the tester.
   
This technique is useful for debugging your definition.

3. Run the test

Make sure you set the "executor" type back to the value above:

   "type": "SqlDump"

Execute the following command:

java -jar DbUnitTester.jar persons.ut.json > MyETLStaging_UnitTest.sql

This will produce a file containing SQL statments that carry out the unit test 
cases described in your file.

Extending DbUnitTester
----------------------
1. Create custom executor. 

We showed you how you can use different executors to generate SQL and dump the 
test definition.

You can create custom Java class that implements the extends the Executor class.
Name it xxxExecutor.

For example. Dump executor class is named DumpExecutor. Sql generator class is 
named SqlDumpExecutor.

2. Create custom validators


dbunittester's People

Contributors

ivangeorgiev avatar

Stargazers

 avatar

Watchers

 avatar  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.