|
<< Click to Display Table of Contents >> Test cases (regressions) |
![]() ![]()
|
The Gekko source code contains a large number of so-called regression cases (also known as unit tests). Regression testing has nothing to do with regression in the statistical sense of the word (like linear regression). The tests are found in the project UnitTests, in the file UnitTests.cs.
Test cases typically either test some small part of the source code, to check that it (still) works as intended. A test case could be for instance to create a new Series object of some frequency, put some data into it via its SetData() method (for different dates), and then read the data again for the same dates. The check would be that the data read is the same as the data stored. If this is not so, the test fails. Such a test may seem superfluous right after the Series component has been written (and tested while being written). But consider this scenario: several years later there might be a request to change something about the time series functionality. The programmer may have forgotten most details regarding the inner working of the Series object and its methods, and may change something that breaks something else (that is, has unintended side-effects). The test cases check that the classes and methods still work as intended, and in this sense they may be seen as 'contracts'. A 'contract' for a timeseries may for instance be that if some value is stored at a particular date in a time series, the same value should be obtained when querying the same timeseries regarding the same date.
Gekko contains a large number of such test cases that run pretty quickly even though they are pretty large in number (takes about 30 min). So while changing the source code, these tests can be performed automatically whenever the programmer wants it.
In addition to these small tests, there are some larger tests running more "realistic" Gekko programs and functionality. Typically, these are collections of command files that produce a given scenario given a model and some input data. Gekko runs these scenarios and checks that the results do not diverge from what is obtained from earlier versions of Gekko. These tests are more time-consuming, but may catch other kinds of unexpected bugs.
The tests are run before each release of a new Gekko version.