Skip to content

joshiayush/xtest


Logo

xtest

C++ testing framework inspired by googletest!
Explore the docs »

Wiki · Report Bug · Request Feature

xtest is a C++ testing framework inspired by gtest. This is just a minimal implementation of a C++ unit testing framework which gives all the required facilities for unit testing a software without going template crazy and causing compilation issues.

A better and more robust version of this library is GoogleTest which is developed and maintained by Google. It is a official Google product and is used by many notable projects.

Installation

Clone the repository.

git clone https://github.com/joshiayush/xtest.git

Install libxtest

sudo chmod +x ./tools/install_libxtest.sh
./tools/install_libxtest.sh

Build samples

To build samples,

cmake -B build/ -S . -DBUILD_SAMPLES:BOOL=ON
cd build
make install

Now run the samples,

./samples/factorial/factorial  # Runs the factorial unit test samples binary
./samples/isprime/isprime      # Runs the isprime unit test samples binary

Usage

Testing a custom function that returns the sqaure of a given number.

#include <xtest/xtest.hh>

double square(int n) {
  return n*n;
}

TEST(TestSquare, TestWithPositiveNumber) {
  EXPECT_EQ(square(10), 100);
}

int32_t main(int32_t argc, char** argv) {
  ::xtest::InitXTest(&argc, argv);
  return RUN_ALL_TESTS();
}

Now compile the file and link the libxtest.so file with it:

g++ -lxtest square_test.cc -o square_test

Contribution

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement", "bug", or "documentation". Don't forget to give the project a star! Thanks again!

Project xtest is hosted on GitHub. If you want to contribute changes please make sure to read the CONTRIBUTING.md file. You can also contribute changes to the CONTRIBUTING.md file itself.

Releases

No releases published

Packages

No packages published