TestsExamples - OpenTrading/OpenTrader GitHub Wiki
Because OTCmd2 is a cmd2 application, not only can it interpret commands in an interactive loop, but it can read a list of commands from the stdin. This can be used to give examples of typical use-cases.
Additionally, as we have Python under the cmd2 loop, we can use Python to make tests or assertions after any step in the script. This makes it easy to write scripts as complete UseCase tests. At the same time, it gives end-users a catalogue of complete working examples.
There are a series of example files in the share/examples directory of the distribution. These example files are OTCmd2 command scripts that you run, for example under Msys or Unix, like this:
OTCmd2 -P "/c/Program Files/MetaTrader" < share/examples/OTCmd2-sub.txt
You should see no AssertionErrors, and you should see no timeouts:
WARN: No retval returned in 60 seconds
(You can adjust the timeout in the [OTCmd2] section of the OTCmd2.ini config file with the key iRetvalTimeout.)
These test runners are written in BASH. To run them under Windows you will need to install a Unix bash, such as http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe
They're not very complicated, so if you don't have a Unix BASH installed, you can just read the scripts and run the commands from a command-line window. Perhaps someone can contribute the .bat script equivalents, even simplified versions.
You can also run the test suite with different configurations by giving it different .ini files, for example under Msys or Unix, like this:
OTCmd2 -c /tmp/My.ini -P "/c/Program Files/MetaTrader" < share/examples/OTCmd2-sub.txt
These examples can be run as a test suite, but some are slow and some require the rabbitq server to be running and some require a Metatrader to be running with a OTPyTestPikaEA.mq4 EA loaded.
We will try to break the examples up into groups to be run under different conditions This script is in Unix bash and should run under Windows using MSYS. Or maybe someone can kindly convert it to MSDOS BAT and upload it to githib.com
We need to know where you have your metatrader installed.
The calling of OTCmd2 may need to be customized for your setup.
Test the communications with Mt4 via RabbitMQ; these tests NEED to have BOTH RabbitMQ and Mt4 running We need to know where you have your metatrader installed.
You MUST have created a CSV file for the tests to work on.
This file is automatically generated from the source code: do not edit.