Catch2
if (NOT TARGET Catch2) project(Catch2 CXX) set(CMAKE_CXX_STANDARD 11) add_library(${PROJECT_NAME} INTERFACE) target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CU ${CMAKE_CURRENT_SOURCE_DIR}/include) # Mimic the library names in Catch2's own CMake files: add_library(Catch2::Catch2 ALIAS Catch2) # This one is historical, left over from when ApprovalTests.cpp cpp was first created. # We could encourage users to move away from it. add_library(catch2 ALIAS Catch2) endif ()0 码力 | 1 页 | 519.00 B | 5 月前3Back to Basics Unit Testing
Modern C++ Testing with Catch2 Catch2 https://github.com/catchorg/Catch2 Frameworks Part 0: Basics 9auto abs(int x) -> int; math.hpp math.cpp test_math.cpp #include <catch2/catch_test_macros.hpp> Frameworks Part 0: Basics 10auto abs(int x) -> int; math.hpp math.cpp test_math.cpp #include <catch2/catch_test_macros.hpp> #include "math.hpp" TEST_CASE("Absolute value tests"){ CHECK( abs( 5) Randomness seeded to: 3662634875 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ output.s is a Catch2 v3.7.0 host application. Run with -? for options ---------------------------------------------------------0 码力 | 109 页 | 4.13 MB | 5 月前3Quickly Testing Qt Desktop Applications With Approval Tests
Test Executable22 C++ Test Runners • Lots to choose from: • Catch2, with a little bit of Qt Test • Tricks needed to use Qt with Catch2 – Useful if using different framework23 Setting up testsuite GoToLineToolFixture() { mGoToLineWidget.raise(); mGoToLineWidget.show(); // ... and so on ...46 Fixtures in Catch2 • Fixtures share code between tests • Also improve test design TEST_CASE_METHOD( GoToLineToolFixture ApprovalTests.cpp.Qt59 Introducing ApprovalTests.cpp.Qt • github.com/approvals/ApprovalTests.cpp.Qt Catch2 ApprovalTests.cpp Qt5 Test Qt5 Widgets ApprovalTests.cpp.Qt60 Introducing ApprovalTests.cpp.Qt0 码力 | 77 页 | 6.96 MB | 5 月前3MACRO-FREE TESTING WITH C++20
COM/BOOST-EXT/UT HTTPS://GITHUB.COM/BOOST-EXT/UT 13 / 14CATCH2 - CATCH2 - HTTPS://GODBOLT.ORG/Z/JFB7JK HTTPS://GODBOLT.ORG/Z/JFB7JK 14 / 14CATCH2 - CATCH2 - HTTPS://GODBOLT.ORG/Z/JFB7JK HTTPS://GODBOLT.ORG/Z/JFB7JK [=]() mutable #define SECTION(name) ut::test{"section", name} = [=]() mutable 14 / 14CATCH2 - CATCH2 - HTTPS://GODBOLT.ORG/Z/JFB7JK HTTPS://GODBOLT.ORG/Z/JFB7JK #define REQUIRE(...) ut::expect(that SECTION("resize bigger") { v.resize(10); REQUIRE(10 == std::size(v)); }; }; 14 / 14CATCH2 - CATCH2 - HTTPS://GODBOLT.ORG/Z/JFB7JK HTTPS://GODBOLT.ORG/Z/JFB7JK #define REQUIRE(...) ut::expect(that0 码力 | 53 页 | 1.98 MB | 5 月前3Back To Basics Debugging and Testing
Tests run fast – tight feedback loop. But… Assumptions!UNIT TESTING FRAMEWORKS ● Google Gest ● Catch2 ● Boost.Test ● CppUTest ● doctestGOOGLE TEST (GTest) // Tests factorial of 0. TEST(FactorialTest EXPECT_EQ(Factorial(2), 2); EXPECT_EQ(Factorial(3), 6); EXPECT_EQ(Factorial(8), 40320); }Catch2 #include <catch2/catch_test_macros.hpp> TEST_CASE( "Factorials are computed", "[factorial]" ) { REQUIRE(0 码力 | 50 页 | 2.04 MB | 5 月前3Cetting Started with C++
microsoft-test-framework-for-cpp Only available with Visual Studio Catch2 https://github.com/catchorg/Catch2 Package Managers: catch2 Boost.Test https://boost.org/libs/test vcpkg: boost-test Conan:0 码力 | 95 页 | 4.71 MB | 5 月前3CMakeLists.txt
cppcon_add_test(basic SOURCES async_event.cpp main.cpp pending.cpp LIBRARIES Asio::asio Catch2::Catch2 basic)0 码力 | 1 页 | 112.00 B | 5 月前3CMakeLists.txt
cppcon_add_test(no_service SOURCES async_event.cpp main.cpp pending.cpp LIBRARIES Asio::asio Catch2::Catch2 no_service)0 码力 | 1 页 | 122.00 B | 5 月前3CMakeLists.txt
cppcon_add_test(complete SOURCES async_event.cpp main.cpp pending.cpp service.cpp LIBRARIES Asio::asio Catch2::Catch2 complete)0 码力 | 1 页 | 130.00 B | 5 月前3添加测试服务
cppcon_add_test(service SOURCES async_event.cpp main.cpp pending.cpp service.cpp LIBRARIES Asio::asio Catch2::Catch2 service)0 码力 | 1 页 | 128.00 B | 5 月前3
共 89 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9