Quickstart Guide
This quickstart shows the smallest setup to produce an Allure report. Pick your test framework tab and copy the snippets.
-
Add dependencies by pasting this into your CMakeLists.txt.
CMakeLists.txtcmake_minimum_required(VERSION 3.14) project(FirstTest) include(FetchContent) FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG v1.14.0 ) FetchContent_MakeAvailable(googletest) FetchContent_Declare( AllureCpp GIT_REPOSITORY https://github.com/sibkru/allure-cpp.git GIT_TAG main ) set(ALLURE_ENABLE_GOOGLETEST ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(AllureCpp) # Your test target add_executable(MyTests main.cpp tests.cpp) target_link_libraries(MyTests PRIVATE AllureCpp gtest gtest_main) -
Use this GoogleTest main in
main.cpp.main.cpp#include <gtest/gtest.h> #include <allure-cpp.h> int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); allure::adapters::googletest::AllureGTest allureHelper; return RUN_ALL_TESTS(); } -
Add your first annotated test to
tests.cpp.tests.cpp#include <gtest/gtest.h> #include <allure-cpp.h> using namespace allure; class LandingPageTests : public ::testing::Test { public: static void SetUpTestSuite() { suite() .name("My Test Suite") .description("This is what your annotated testcases look like.") .epic("library demo") .severity("critical"); } }; TEST_F(LandingPageTests, testWithSteps) { test() .name("Test with multiple steps") .feature("Step-by-Step Execution") .story("User can track test execution with detailed steps"); int result = 0; step("Initialize value to 5", [&]() { result = 5; }); { auto s = step("alternative step syntax"); result *= 2; } step("Add 3 to value", [&]() { result += 3; }); step("Verify result is 13", [&]() { EXPECT_EQ(13, result); }); } -
Run tests and view the report.
- Build and run your tests:
ctestor the test binary. - Find results in
allure-results/and generate the report withallure serve allure-results.
- Build and run your tests:
-
Add dependencies by pasting this into your CMakeLists.txt.
CMakeLists.txtcmake_minimum_required(VERSION 3.14) project(FirstTest) include(FetchContent) FetchContent_Declare( CppUTest GIT_REPOSITORY https://github.com/cpputest/cpputest.git GIT_TAG v4.0 ) set(CPPUTEST_USE_EXTENSIONS ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(CppUTest) FetchContent_Declare( AllureCpp GIT_REPOSITORY https://github.com/sibkru/allure-cpp.git GIT_TAG main ) set(ALLURE_ENABLE_CPPUTEST ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(AllureCpp) # Your test target add_executable(MyTests main.cpp tests.cpp) target_link_libraries(MyTests PRIVATE AllureCpp CppUTest) -
Use this CppUTest main in
main.cpp.main.cpp// Include your headers first so they aren't compiled under CppUTest's new/delete overrides #include <allure-cpp.h> // CppUTest includes come last #include <CppUTest/CommandLineTestRunner.h> #include "Framework/Adapters/CppUTest/AllureCppUTestCommandLineTestRunner.h" int main(int argc, const char* const* argv) { // Initialize Allure and run tests with the Allure-enabled runner allure::adapters::cpputest::AllureCppUTest allureHelper; return allure::adapters::cpputest::RunAllureEnabledTests(argc, argv); } -
Add your first annotated test to
tests.cpp.tests.cpp// Include allure-cpp.h BEFORE CppUTest headers to avoid conflicts with CppUTest's new/delete overrides #include <allure-cpp.h> #include <CppUTest/TestHarness.h> using namespace allure; TEST_GROUP(LandingPageTests) { void setup() override { suite() .name("My Test Suite") .description("This is what your annotated testcases look like.") .epic("library demo") .severity("critical"); } }; TEST(LandingPageTests, TestWithSteps) { test() .name("Test with multiple steps") .feature("Step-by-Step Execution") .story("User can track test execution with detailed steps"); int result = 0; step("Initialize value to 5", [&]() { result = 5; }); { auto s = step("alternative step syntax"); result *= 2; } step("Add 3 to value", [&]() { result += 3; }); step("Verify result is 13", [&]() { CHECK_EQUAL(13, result); }); } -
Run tests and view the report.
- Build and run your tests:
ctestor the test binary. - Find results in
allure-results/and generate the report withallure serve allure-results.
- Build and run your tests: