Unit Tests

Unit tests can be used to evaluate program functions and / or classes directly. You can either enter the class/function names and/or class/function parameters and the expected values or write your own unit test.

Here is a brief list of some of the unit testing frameworks that are installed on their respective stack environment.

Stack

Test Framework(s)

C#

nunit

C++

gtest

Java

JUnit

JavaScript / Node.js

mocha/chai/sinon

Python

unittest

Swift

XCTest

Adding a Unit Test

To add an unit test, navigate to Checks in the left sidebar and use the New Check + button. Next, select the Unit Test option in the drop-down and see the settings below:

Common Settings

Settings that are used for both basic and advanced unit tests are shown below.

Description

A summary of what this unit test is checking. Shown to users if the task is live and checks are shared (which is the default).

Advanced

Toggle this to show the advanced unit test form.

Unit Test settings - Advanced enabled

The advanced unit test template allows you to write unit tests using your own code. Each advanced unit test template comes with an example of the testing module for that test framework in that environment.

Imports

A list of files to import into the unit test (e.g. header files, source files). Add one per line.

Basic Form Settings

Class Name

The optional name of the class to instantiate an instance of to test.

Class Parameters

The optional parameters to use when initializing the class instance.

Function

The function to call. If a class name is provided, this will be called against the instantiated class instance.

Parameters

The parameters to pass to the function.

Operator

The comparison operator to use.

Value

The value the function should return.

Advanced Form Settings

Test Contents

The full test contents (excluding imports) to run.

Command

Optionally specify a command to run the unit test.