r/cpp • u/onqtam github.com/onqtam/doctest • May 22 '16
doctest - the lightest feature rich C++ single header testing framework - version 1.0 released!
https://github.com/onqtam/doctest
76
Upvotes
22
u/[deleted] May 22 '16
Do not underestimate this. I've started including tests alongside some of the hairier code and it removes one barrier to writing tests. Low compile-times removes another. Definitely checking this out! Thanks for posting.
9
u/Kronikarz May 22 '16
Oh.
7
u/mintyc May 22 '16
Anyone able to compare this to catch. My favourite header only test framework?
2
u/Sinity May 22 '16 edited May 22 '16
How does it work when you mix tests with production code? I mean, do I somehow get real executable and one with tests(by using some flags passed to the compilator), or are tests somehow combined with application executable(so I pass some argument to the commandline if I want to run test suite)? I'm a bit confused about it.
Also, if one decides to write unit tests in that style, I think best way would be putting all tests relevant to the class right below it, all tests relevant to a given method right below it, the same with functions. And then using some IDE/editor feature to automatically fold tests until you want to see them. But I'm not sure if any IDE would make it simple. Maybe vim is configurable enough to do that, through. Or is there an option to fold only macros in mainstream IDE's?
Also, how does it compare directly with Catch? Apart from performance, are there any additional advantages or disadvantages you can think of?
1
u/cleroth Game Developer May 22 '16
How does it compare to Visual Studio's Testing framework, other than being portable?
1
u/wichtounet May 25 '16
This is incredible!
If this can speedup the compilation of my tests, I'm trying it! I was looking at converting one of my source file and I'm wondering if there is any support for
SECTIONas in Catch ?1
u/crowseldon May 22 '16
Like catch but fast compilation times? I like the idea. Specially for TDD and stuff... I'll have to check it out soon.
0
u/[deleted] May 22 '16
I'm reading through the headers and finding that there is a bunch of stuff I'd never use like fixtures. Given that you're focusing on performance have you considered allowing the user to bypass parsing parts of the file somehow? I wonder if that would give any performance boost.