对于C/ c++,有好的开源BDD工具吗?

时间:2023-01-19 23:30:53

I love the Ruby RSpec BDD development style. Are there any good tools for doing this with C/C++?

我喜欢Ruby RSpec BDD开发风格。有什么好的工具可以用C/ c++实现这一点吗?

6 个解决方案

#1


14  

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.

cspec是针对C的,它可能会与c++一起工作。在行为驱动的开发*页面上有一个各种语言的工具列表。

#2


4  

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

看来您可以使用Ruby和RSpec来测试您的C代码,并使用swig生成包装器!请参阅Ben Mabey的文章:http://benmabey.com/2007/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.

我试过这个例子,它对我很有用。我不确定是否有人更进一步。

#3


4  

The original link (CppSpec) is dead, but it is still accessible at the Internet Archive at CppSpec.

原始链接(CppSpec)已经失效,但在CppSpec的Internet归档中仍然可以访问它。

And as @VickyChijwani already mentioned, there's a copy of the project at Github - tpuronen/cppspec

正如@VickyChijwani所提到的,Github - tpuronen/cppspec中有一个项目的副本。

#4


3  

Igloo is one I'm looking forward to try some time

冰屋是我期待着尝试的一个

#5


2  

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.

由于需要一个类似RSpec的框架,我想添加最近的冰屋。虽然最初的目标是上下文/规范语法,但它也支持描述/ it语法。在设置测试运行器和测试装置时,不会像那些基于c的框架那样有太多的干扰。它甚至感觉比CppSpec更好。他们通过使用合适的模板机制来实现这一点。

#6


2  

Try CBehave! It is an RSpec-like BDD framework that uses given/when/then macros. Example:

CBehave试试!它是一个类似rspec的BDD框架,使用给定/when/then宏。例子:

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

#1


14  

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.

cspec是针对C的,它可能会与c++一起工作。在行为驱动的开发*页面上有一个各种语言的工具列表。

#2


4  

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

看来您可以使用Ruby和RSpec来测试您的C代码,并使用swig生成包装器!请参阅Ben Mabey的文章:http://benmabey.com/2007/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.

我试过这个例子,它对我很有用。我不确定是否有人更进一步。

#3


4  

The original link (CppSpec) is dead, but it is still accessible at the Internet Archive at CppSpec.

原始链接(CppSpec)已经失效,但在CppSpec的Internet归档中仍然可以访问它。

And as @VickyChijwani already mentioned, there's a copy of the project at Github - tpuronen/cppspec

正如@VickyChijwani所提到的,Github - tpuronen/cppspec中有一个项目的副本。

#4


3  

Igloo is one I'm looking forward to try some time

冰屋是我期待着尝试的一个

#5


2  

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.

由于需要一个类似RSpec的框架,我想添加最近的冰屋。虽然最初的目标是上下文/规范语法,但它也支持描述/ it语法。在设置测试运行器和测试装置时,不会像那些基于c的框架那样有太多的干扰。它甚至感觉比CppSpec更好。他们通过使用合适的模板机制来实现这一点。

#6


2  

Try CBehave! It is an RSpec-like BDD framework that uses given/when/then macros. Example:

CBehave试试!它是一个类似rspec的BDD框架,使用给定/when/then宏。例子:

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