Test Results
To test your data, you can add something like this to a manager script:
using System;
using Models.Core;
namespace Models
{
[Serializable]
public class Script : Model, ITest
{
public void Run()
{
bool testHasFailed = true;
if (testHasFailed)
throw new Exception("oh dear");
}
}
}
Things to note:
- Any failures should be handled by throwing an exception.
- Whenever Apsim finishes running simulations, it will run all
IModels which implement theITestinterface. Therefore, the script must inherit fromModel ITestis defined in theModels.Corenamespace- By default, Apsim will not run these tests when run from the command line, unless the
--run-testscommand line switch is provided. If you don't know what the command line is, this will not affect you. - Jenkins will run these tests whenever a pull request is run. Therefore, all files under the Examples, Prototypes, and Tests directories are guaranteed to be tested.
