Skip to content

Latest commit

 

History

History
80 lines (64 loc) · 2.36 KB

README.md

File metadata and controls

80 lines (64 loc) · 2.36 KB

nosh

nosh is a no shit C++ test framework

Why write tests with nosh?

  1. What you see is what you get. No magic behind your back.
  2. No shoutcased macros
  3. A test is a simple C++ class. An assertion is a simple method of the Test class with defined syntax.
  4. Easy to understand and get started.
  5. Develop parameter based tests. Easily generate parameters for tests using Generators.

Getting started

  1. Download nosh.hpp or clone this repository
  2. Make sure nosh.hpp is in one of your project's include paths
  3. Follow the tutorial section to add test cases to your project using nosh

Tutorial

Simple test

class SimpleTest: public Test {
public:
  SimpleTest() {
    //TODO Construction goes here
  }
  
  virtual ~SimpleTest() {
    //TODO Destruction goes here
  }
  
  virtual void run() {
    //TODO Test logic goes here
  }
};

int main(void) {
  execTest(SimpleTest());
}

Assertions

Basic assertions

Fatal assertion Nonfatal assertion Verifies
assertTrue(condition); expectTrue(condition); condition is true
assertFalse(condition); expectFalse(condition); condition is false

Binary assertions

Fatal assertion Nonfatal assertion Verifies
assertEQ(val1, val2); expectEQ(val1, val2); val1 == val2
assertNE(val1, val2); expectNE(val1, val2); val1 != val2
assertLT(val1, val2); expectLT(val1, val2); val1 < val2
assertLE(val1, val2); expectLE(val1, val2); val1 <= val2
assertGT(val1, val2); expectGT(val1, val2); val1 > val2
assertGE(val1, val2); expectGE(val1, val2); val1 >= val2

Test with assertions

TBD

Test with parameters

TBD

Generating parameters

TBD

Creating generators

TBD

Features

  • Test fixtures
  • Basic and binary assertions
  • Tests with parameters
  • Parameter generators
  • Print information about test case before run. Print parameters in case parameters are involved
  • Versbose/No verbose command line flag
  • Filter tests from command line
  • Filter tests programatically
  • Export test results in JSON, XML