HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
catchorg
Catch2
C++2011–2025
catchorg / Catch2

Catch2

A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later (C++11 support is in v2.x branch, and C++03 on the Catch1.x branch)

15Distinct people
15Mentions
0Explicit recommenders
21.6KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later (C++11 support is in v2.x branch, and C++03 on the Catch1.x branch)

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 12:54:37 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year15 dated mentions

Observed mentions: 2011-01-30 22:15:46 UTC to 2025-03-14 07:41:48 UTC.

012342011-01-01 00:00:00 UTC to 2012-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20112012-01-01 00:00:00 UTC to 2013-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2013-01-01 00:00:00 UTC to 2014-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-01-01 00:00:00 UTC to 2015-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments2015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 4 mentions; 1 submissions, 3 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20112011-01-01 00:00:00 UTC2012-01-01 00:00:00 UTC101
20122012-01-01 00:00:00 UTC2013-01-01 00:00:00 UTC101
20132013-01-01 00:00:00 UTC2014-01-01 00:00:00 UTC000
20142014-01-01 00:00:00 UTC2015-01-01 00:00:00 UTC312
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC101
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC000
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC202
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC000
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC000
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC413
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC000
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC000
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC211
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC101

What Hacker News says

15 sources
The C++ testing framework Catch2 enables this kind of testing. The first time I saw it I couldn't figure out how some of the tests would even pass. It turns out that using some evil macro magic, each test re-runs from the start for each inner section [1]. It also makes deduplicating setup code completely painless and natural. You just have to get over the completely non-standard control flow. It's a good standard bearer for why metaprogramming is great, even if you're forced to do it in C/C++'s awful macro system. [1] https://github.com/catchorg/Catch2/blob/devel/docs/tutorial....
In Functional Tests as a Tree of Continuations (2010)
1. Could you give a few examples of libraries that can’t be made in Rust due to lack of abstraction compared to C++? I'm guessing, but I think that something like Armadillo[1] would not be possible on stable Rust. Something like Catch[2] might also difficult to make ergonomic. I don't program in C++ anymore and I would personally live with the lack of expression/abstraction for a safer language though. [1] http://arma.sourceforge.net/speed.html [2] https://github.com/catchorg/Catch2/blob/master/docs/tutorial...
In Ask HN: Why do you use Rust, when D is available?
My biggest improvement came from eliminating a tool. It was when I stopped using debuggers (except maybe once a year) and invested more time in creating efficient runtime error checks and internal self-tests. Debuggers make me lazy. I find I can solve the vast majority of my bugs more quickly with a little thought rather than running to a breakpoint and examining things. Most useful tools: - tmux - vim - catch (https://github.com/catchorg/Catch2)
In Ask HN: Which tools have made you a much better programmer?
Meh. Like, who the hell wants to have to restate their conditions twice? Not me, that's for sure. What you need is something more like this. (I'll write out one case, and you can figure out the rest.) It's more lines, but I don't think you'll feel like it's bad value per LOC. For the actual condition you write in your code, you want a macro that expands to something with __FILE__ and __LINE__, and uses the stringizing operator to get the LHS and RHS as strings. Here's one that compares to ints (hence II) for equality (hence EQ). #define TEST_EQ_II(A,B) (DoTestEqII((A),#A,(B),#B,__FILE__,__LINE__)) The function that implements that. Note that because C is stupid, the int parameters basically have to be int64_t... \this isn't really a problem in practice. void DoTestEqII(int64_t a,const char *a_str, int64_t b,co
Read the rest
nst char *b_str, const char *file,int64_t line) { DoTestII(a,a_str,b,b_str,file,line,a==b,"=="); } Clearly I'm all about the layering, and here's the next layer. void DoTestII(int64_t a,const char *a_str, int64_t b,const char *b_str, const char *file,int64_t line, int result,const char *oper) { if(!result) { Print("%s%s%" PRId64 "%s: test failed\n",file,LINE_PREFIX,line,LINE_SUFFIX); Print(" Expected expression: %s\n",a_str); Print(" Operator: %s\n",oper); Print(" Actual expression: %s\n",b_str); Print(" Expected value: %" PRId64 " (0x%" PRIx64 ")\n",a,a); Print(" Actual value: %" PRId64 " (0x%" PRIx64 ")\n",b,b); Break(); } } For VC++: #define Break() __debugbreak() #define LINE_PREFIX "(" #define LINE_SUFFIX ")" Then make Print print via OutputDebugString (VS2015 does C99-style snprintf, so this is easy to arrange perfectly), so the output goes to the output window. Visual Studio treats output window lines beginning like "FILE(LINE):" as referring to source locations, so when you get a failing test you can just tap F8 - I think? I'm not in Windows right now - and you'll be taken to the line and file with the error. For POSIX-type stuff, e.g., Emacs: #define Break() asm volatile ("int $3\n") /* if you get a build error here, your computer is shit. */\ /* Throw it away, and buy a proper one, with an x64 CPU. */ #define LINE_PREFIX ":" #define LINE_SUFFIX "" And make Print print to stderr. I typically run my tests as part of the build process, invoked via M-x compile, and Emacs then picks up the FILE:LINE: markup when you use M-x next-error and M-x previous-error. (If you use vim, or whatever... I'm sorry. But lesser editors often understand the standard FILE:LINE: markup, so even when you're slumming it, you're not, like, totally slumming it.) You can probably figure out how this extends from int equals int to int not equals int, int less than int, blah blah... and from there to string vs string, and double vs double, and so on. It's not really the operations that are the key thing, because of course they're easy to add; for my money the benefit comes from auto-generating the output text from the condition, and from having it integrate tidily with the calling process - Visual Studio, Emacs, other (notepad, vim, etc.) - in such a way that you can jump immediately to the source location when a test fails. Where the article and I do agree: the conclusion, all of it. Writing a unit test system isn't hard, and writing your own isn't crazy. It probably won't take you even one hour. P.S. if you like C++, you can go one better, and have the output text auto-generated without even having to say what sort of comparison it is: https://github.com/philsquared/Catch Only downside is that while you'll save one hour not writing your own, you'll lose ten hours waiting for it to compile. Also, good luck trying to write test programs that have command line options. This is what I believe they call "technical debt".
In MinUnit: a minimal unit testing framework for C
I created this framework to automate tests in ccv: http://github.com/liuliu/ccv. Now it is a very "weak" framework comparing to others. The highlight is: simple and pure C. Granted, some hacks are needed to complete this job. But I hope that these hacks are robust enough to be usable. I am looking for a test framework for some time already and I liked the structure of CATCH (https://github.com/philsquared/Catch) a lot but the only downside is that it is C++ based (I don't want to extern "C" link to my C library). It should be understood that for a good test framework, C may not be syntactically powerful enough to support such syntax sugar. JUnit made heavily use of annotation and many C++ unit testing libraries use static object with constructor (to collect all test cases before main starts). I managed to do this with some macros and stac
Read the rest
k hacking. I plan to have some mutation test support in the future.
In CASE: a Simple Test Framework for C

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.