Note: This page is for showing how to run qUnit tests within qStudio
for details on the qUnit framework itself see the qUnit Testing Framework page.

qUnit is a framework for unit testing q code
It is heavily based on the xUnit/jUnit testing frameworks. qUnit can be ran from the tools menu, when called it will execute the code in the currently open file and run all tests contained within.

Running unit tests within kdb

Running Example Tests

Opening example unit tests within qStudio IDE

To run some example unit tests:

  1. Goto "Help Menu"->"open qunit example .q", this will open two q source files (math.q and mathTest.q)
  2. Select the math.q file and press Ctrl+E to load that onto the current server.
  3. Select the testMath.q file and press Ctrl+T to run the tests.
    This loads the qUnit framework onto the server in the .qunit namespace and executes the tests.
  4. You will receive a table of results like so:

Unit test results within qStudio

Notice two of the tests failed and their assertion messages are returned to let the developer know what went wrong.
The rightmost columns contain time/memory used during test.

qUnit - Code Structure

From the examples you can see the qUnit framework enforces a specific structure for tests, this encourages best practices and helps other team members quickly understand the code. Tests should be declared in a separate file within the source code directory and within the file, the functions should be in a namespace. For full details on qUnit and how to create tests see the qUnit Framework Guide Page