Coder Social home page Coder Social logo

wildfoxstudio / bitter---testing-framework Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 235 KB

Single header testing framework

License: GNU General Public License v3.0

C++ 100.00%
automation-test automation-testing framework unit-testing xunit xunit-tests bitter

bitter---testing-framework's Introduction

Bitter

Single Header Testing Framework

Alt text

Just drop it inside your project and you're ready to go. Easy to use and implement, useful on small projects when you don't want dependency to huge testing frameworks. They already many exists single header testing framework, but this is my own, and it's similar to how unreal engine implements automation testing.

Logging to a file

When launching the executable you can pass a filename that will be used a log (the path must exist) ~ test.exe testResult.txt

Usage

With macros

// Test class definition
// example file: myclass.test.cpp

  TEST_DEFINE_CLASS(MyTestClass) // Class name must be unique
          int RandomNumberAboveZero();
          int MyVariable{};
  TEST_END_CLASS(MyTestClass)

  void MyTestClass::Define()
  {
      //Define our test cases
      TestCase("MyVariable should not be zero", [this]() {
          MyVariable = RandomNumberAboveZero();
          TEST_NEQUAL(0, MyVariable);
      }
  }

// example file: main.test.cpp
  #include "bitter.h"
  int main(int argc, char* argv[])
  {
      RUN_ALL_TESTS(argc, argv);
  };

Without macros

// Test class definition
// example file: myclass.test.cpp
  class MyTestClass final : public bitter::AutomatedTestInstance {
     public:
          virtual void Define() override;
     protected:
          int RandomNumberAboveZero();
          int MyVariable{};
  };

  //Register class statically or add it manually in the main.test.cpp but not both
  static bitter::TestInserter<MyTestClass> RegisterMyTestClass("MyTestClass");

  void MyTestClass::Define()
  {
      //Define our test cases
      TestCase("MyVariable should not be zero", [this]() {
          MyVariable = RandomNumberAboveZero();
          TEST_NEQUAL(0, MyVariable);
      }
  }

// example file: main.test.cpp

  #include "foxtest.h"

  int main(int argc, char* argv[]) {
     bitter::AutomationTester engineTester;
     engineTester.AddTest<MyTestClass>("MyTestClass");
     engineTester.AddTest<MyOtherTestClass>("MyOtherTestClass");

     return engineTester.RunAllTests(argc, argv);
 };

bitter---testing-framework's People

Contributors

wildfoxstudio 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.