I love the Ruby RSpec BDD development style. Are there any good tools for doing this with C/C++?
-
3Is this question about C or about C++? C/C++ is nothing but pure ambiguity.– amit kumarSep 13, 2011 at 9:04
-
I'm surprised there's no mention of cucumber-cpp, it's an active framework and uses the Gherkin syntax to write the scenarios. It also has a pretty neat set of options to cover many needs.– fduffAug 14, 2018 at 13:36
6 Answers
cspec is for C. Presumably it will work with C++. There is a list of tools for various languages on the Behavior Driven Development Wikipedia page.
-
-
5
-
1Because he answered first and with an additional link with lots of information. Nov 9, 2011 at 22:03
It seems you can test your C code using Ruby and RSpec using swig to generate wrappers! See Ben Mabey's post here: http://benmabey.com/2007/09/09/bdd-your-c.html
I've tried that example out and it worked for me. I'm not sure if anyone has taken it any further.
The original link (CppSpec) is dead, but it is still accessible at the Internet Archive at CppSpec.
And as @VickyChijwani already mentioned, there's a copy of the project at Github - tpuronen/cppspec
-
4
-
It seems to be the same. Both, the Github repository and CppSpec (Internet archive) are signed by Timo Puronen. Nov 10, 2015 at 7:16
Igloo is one I'm looking forward to try some time
-
it doesn't seem to have any of the characteristics of Cucumber nor Fitnesse, the test is still in the code and it is not readable/editable from tester or business analyst. Nov 10, 2016 at 15:50
-
1I don't think igloo-testing.org is a valid website (at least not any longer).– MrMasFeb 15, 2019 at 14:54
-
@MrMas is correct. URL appears to go to parked domain / redirect to sketchy places. GitHub repo still exists (June 2019) though: github.com/joakimkarlsson/igloo– jacobqJun 19, 2019 at 11:31
Since an RSpec like framework was requested, I'd like to add the recent igloo. Though originally aiming at Context/Spec syntax, it also supports Describe/It syntax. There isn't much noise in setting the test runner and test fixtures up like in those C-based frameworks. It even feels better to look at than CppSpec. They achieve this through use of decent templating mechanics.
-
I don't think igloo-testing.org is a valid website (at least not any longer).– MrMasFeb 15, 2019 at 14:53
Try CBehave! It is an RSpec-like BDD framework that uses given/when/then macros. Example:
FEATURE(1, "strstr")
SCENARIO("The strstr finds the first occurrence of the substring in the source string")
GIVEN("A source string: [Lionel Messi is a great football player]")
char *str = "Lionel Messi is a great football player";
GIVEN_END
WHEN("we use strstr to find the first occurrence of [football]")
char *p = strstr(str, "football");
WHEN_END
THEN("We should get the string: [football player]")
SHOULD_STR_EQUAL(p, "football player");
THEN_END
SCENARIO_END
FEATURE_END