Unit tests can be used to evaluate program functions and / or classes directly.
Here is a brief list of some of the unit testing frameworks that are installed on their respective stack environment:
C# - nunit
Java - JUnit
Python - unittest
C++ - gtest
Swift - XCTest
A unit test's options are described in detail below.
Options that are used for both basic and advanced unit tests are shown below.
A summary of what this unit test is checking. Shown to users if test is shared.
Toggle the advanced unit test form.
The advanced unit test template allows you to write unit tests the traditional way. Each advanced unit test template comes with an example of the testing module for that test framework in that environment.
A list of files to import into the unit test (e.g. header files, source files). Add one per line.
The optional name of the class to instantiate an instance of to test.
The optional parameters to use when initializing the class instance.
The function / method to call. If a class name is provided, this will be called against the instantiated class instance.
The parameters to pass to the function / method.
The comparison operator to use.
The value the function / method should return.
The full test contents (excluding imports) to run.
Optionally specify a command to run the unit test.
This unit test is testing to determine that a method,
.add(), correctly adds the value of
x to a set. Another unit test might test the result of adding
-x to the set, where the set should handle
x in two different ways.
Test Output - Test output is the result of the unit test. Unit tests are small snippets of code on their own so there may be additional information that is generated to the benefit of the reader. This is also an area where users may become confused as unit test output can be complicated and verbose, containing lots of low level information a user is not familiar seeing. it is important to create unit tests with this possibility in mind.
Test Contents - contains the contents of the unit test or unit tests, as there can be multiple. This is the code that is being run against the user's code. In certain circumstances the unit test will be above the user's skill level in that language. The content of a unit test is not designed to be user-friendly, it is designed to test the code.