Giter Club home page Giter Club logo

mt4-unittest's Introduction

mt4-unittest

![Gitter](https://badges.gitter.im/Join Chat.svg)

status

Description

This is a unit testing library for MetaTrader 4.

Requirements

MetaTrader 4, which supports MQL 5. Some knowledges about MQL, unit testing and test driven development.

Installation

  1. Git clone this repository
  2. Copy MQL4/Include/UnitTest.mqh and also MQL4/Include/UnitTest_config.mqh to %APPDATA%/MetaQuotes/Terminal/<ID>/MQL4/Include
  3. Copy MQL4/Experts/test_unittest.mq4 to %APPDATA%/MetaQuotes/Terminal/<ID>/MQL4/Experts
  4. Enable AutoTrading AutoTrading
  5. Drag and drop expert advisor test_unittest.mq4 to a chart EA_running
  6. See top left comment message. You will get something like comment_summary_ok if unit test is passing fine or, if unit test fails: comment_summary_fail
  7. Have a look at Experts tab. You should get log message with either "OK" or "FAIL" for the whole unit test but also for each test case (with statistics for each asserts) ExpertsTab
  8. Modify test_unittest.mq4 to test your own MQL code

Experts tab log messages sample

2014.06.20 17:43:02.055	test_unittest EURUSD,M15: initialized
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:     OK     - Total: 7, Success: 7 (100.00%), Failure: 0 (0.00%)
2014.06.20 17:43:02.055	test_unittest EURUSD,M15: asserts: Total: 9, Success: 9 (100.00%), Failure: 0 (0.00%)
2014.06.20 17:43:02.055	test_unittest EURUSD,M15: ================
2014.06.20 17:43:02.055	test_unittest EURUSD,M15: UnitTest summary
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::testGetMAArray_shoudReturnCoupleOfSMA -     OK     - Total: 2, Success: 2 (100.00%), Failure: 0 (0.00%)
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::testGetMAArray_shoudReturnCoupleOfSMA - endTestCase
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:     MyUnitTest::testGetMAArray_shoudReturnCoupleOfSMA -     OK     - MA array must contains a couple of SMA
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::testGetMA_shoudReturnSMA - Running new test case
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   initTestCase before every test
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::testGetMA_shoudReturnSMA -     OK     - Total: 1, Success: 1 (100.00%), Failure: 0 (0.00%)
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::testGetMA_shoudReturnSMA - endTestCase
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:     MyUnitTest::testGetMA_shoudReturnSMA -     OK     - MA must be SMA and 3 bars shifted
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_05_float_assertEquals_succeed - Running new test case
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   initTestCase before every test
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_05_float_assertEquals_succeed -     OK     - Total: 1, Success: 1 (100.00%), Failure: 0 (0.00%)
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_05_float_assertEquals_succeed - endTestCase
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:     MyUnitTest::test_05_float_assertEquals_succeed -     OK     - assertEquals with 2 floats should succeed
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_04_integers_long_assertEquals_succeed - Running new test case
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   initTestCase before every test
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_04_integers_long_assertEquals_succeed -     OK     - Total: 1, Success: 1 (100.00%), Failure: 0 (0.00%)
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_04_integers_long_assertEquals_succeed - endTestCase
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:     MyUnitTest::test_04_integers_long_assertEquals_succeed -     OK     - assertEquals with 2 integers should succeed
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_03_integers_int_assertEquals_succeed - Running new test case
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   initTestCase before every test
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_03_integers_int_assertEquals_succeed -     OK     - Total: 1, Success: 1 (100.00%), Failure: 0 (0.00%)
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_03_integers_int_assertEquals_succeed - endTestCase
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:     MyUnitTest::test_03_integers_int_assertEquals_succeed -     OK     - assertEquals with 2 integers should succeed
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_02_bool_assertFalse_succeed - Running new test case
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   initTestCase before every test
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_02_bool_assertFalse_succeed -     OK     - Total: 1, Success: 1 (100.00%), Failure: 0 (0.00%)
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_02_bool_assertFalse_succeed - endTestCase
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:     MyUnitTest::test_02_bool_assertFalse_succeed -     OK     - assertFalse should succeed
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_01_bool_assertTrue_succeed - Running new test case
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   initTestCase before every test
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_01_bool_assertTrue_succeed -     OK     - Total: 2, Success: 2 (100.00%), Failure: 0 (0.00%)
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   MyUnitTest::test_01_bool_assertTrue_succeed - endTestCase
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:     MyUnitTest::test_01_bool_assertTrue_succeed -     OK     - assertTrue should succeed
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:     MyUnitTest::test_01_bool_assertTrue_succeed -     OK     - assertTrue should succeed
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:    - Running new test case
2014.06.20 17:43:02.055	test_unittest EURUSD,M15:   initTestCase before every test
2014.06.20 17:43:02.055	test_unittest EURUSD,M15: ================
2014.06.20 17:43:02.055	test_unittest EURUSD,M15: UnitTest - start
2014.06.20 17:43:02.049	Expert test_unittest EURUSD,M15: loaded successfully

mt4-unittest's People

Contributors

femtotrader avatar gitter-badger avatar micclly avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.