Giter Site home page Giter Site logo

m4a1x / arduinofake Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fabiobatsilva/arduinofake

0.0 0.0 0.0 144 KB

Arduino mocking made easy

Home Page: https://platformio.org/lib/show/1689/ArduinoFake

C++ 88.11% C 11.24% CMake 0.55% Makefile 0.10%

arduinofake's Introduction

ArduinoFake

Build Status

ArduinoFake is a simple mocking framework for Arduino. ArduinoFake is based on FakeIt and can be used for testing your arduino project natively. No arduino required !

Quickstart

Includes

You should include the following header in your test file:

#include <ArduinoFake.h>

Stubbing

Assuming we have the following arduino code:

// src/main.cpp
void loop()
{
    // turn the LED on (HIGH is the voltage level)
    digitalWrite(LED_BUILTIN, HIGH);
    // wait for a second
    delay(100);
    // turn the LED off by making the voltage LOW
    digitalWrite(LED_BUILTIN, LOW);
     // wait for a second
    delay(100);
}

It can be tested using ArduinoFake:

#include <ArduinoFake.h>

using namespace fakeit;

// test/test_main.cpp
void test_loop(void)
{
    When(Method(ArduinoFake(), digitalWrite)).AlwaysReturn();
    When(Method(ArduinoFake(), delay)).AlwaysReturn();

    loop();

    Verify(Method(ArduinoFake(), digitalWrite).Using(LED_BUILTIN, HIGH)).Once();
    Verify(Method(ArduinoFake(), digitalWrite).Using(LED_BUILTIN, LOW)).Once();
    Verify(Method(ArduinoFake(), delay).Using(100)).Exactly(2_Times);
}

Checkout the examples for many more examples! Or take a look at the tests

Contributing

If you want to extend ArduinoFake library to add missing functions (for example attachInterrupt) see contribution guidelines.

arduinofake's People

Contributors

fabiobatsilva avatar vvvlc avatar dolfandringa avatar wrong-kendall avatar tomec-martin avatar m4a1x avatar valeros 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.