I have written few c++ Unit tests using CPPUnit
我用CPPUnit编写了很少的c ++单元测试
But I do not understand how to run those.
但我不明白如何运行它们。
Is there any tool like Nunit-gui?
有没有像Nunit-gui这样的工具?
Currently I have written and packed tests in a DLL.
目前我已经在DLL中编写并打包了测试。
When i google i found this http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html
当我谷歌我发现这http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html
But i am not able to understand how does it get tests from a DLL.
但我无法理解它是如何从DLL获取测试的。
Thanks in advance
提前致谢
3 个解决方案
#1
Group your TestCases into TestSuite, write a main(), compile, link against the cppunit library and run the executable from the command-line.
将TestCases分组到TestSuite,编写main(),编译,链接cppunit库并从命令行运行可执行文件。
Here is an example of a main function.:
这是一个主要功能的例子:
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
int main( int ac, char **av )
{
//--- Create the event manager and test controller
CPPUNIT_NS::TestResult controller;
//--- Add a listener that colllects test result
CPPUNIT_NS::TestResultCollector result;
controller.addListener( &result );
//--- Add a listener that print dots as test run.
CPPUNIT_NS::BriefTestProgressListener progress;
controller.addListener( &progress );
//--- Add the top suite to the test runner
CPPUNIT_NS::TestRunner runner;
runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
runner.run( controller );
return result.wasSuccessful() ? 0 : 1;
}
If you really want a GUI, there is QxRunner.
如果你真的想要一个GUI,那就有QxRunner。
#2
I would suggest people to use cppunit in visual studio if you are on windows and if you are testing for C++. How to configure cppunit in visual studio and how to use it with example? if you have downloaded the cppunit file. Then in your visual studio project you need to set few things
如果你在Windows上,如果你正在测试C ++,我建议人们在visual studio中使用cppunit。如何在visual studio中配置cppunit以及如何在示例中使用它?如果你已经下载了cppunit文件。然后在您的visual studio项目中,您需要设置一些东西
1). Give the path of include folder inside your cppunit file at location of your visual studio project, Project properties > C/C++ > General > Additional include directories.
1)。在Visual Studio项目的位置为cppunit文件提供include文件夹的路径,项目属性> C / C ++>常规>其他包含目录。
2). Give the path of lib folder inside your cppunit file at location of your visual studio project, Project properties > Linker > General > Additional library directories.
2)。在Visual Studio项目的位置为项目属性>链接器>常规>其他库目录提供cppunit文件中的lib文件夹路径。
3). Add a file "cppunit.lib" at location of your visual studio project, Project properties > Linker > Input > Additional Dependencies.
3)。在Visual Studio项目的位置添加文件“cppunit.lib”,项目属性>链接器>输入>附加依赖项。
Follow the step by step procedure in the link below
按照以下链接中的分步过程进行操作
http://www.areobots.com/unit-testing-with-cppunit-visual-studio-configuration/
http://www.areobots.com/how-to-do-unit-testing-with-cppunit-with-example/
#3
As mentioned in following link http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/checkout/sync4j/tools/cppunit/INSTALL-WIN32.txt?rev=1.1.1.1
如以下链接中所述http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/checkout/sync4j/tools/cppunit/INSTALL-WIN32.txt?rev=1.1.1.1
TestPlugInRunner can be used
可以使用TestPlugInRunner
#1
Group your TestCases into TestSuite, write a main(), compile, link against the cppunit library and run the executable from the command-line.
将TestCases分组到TestSuite,编写main(),编译,链接cppunit库并从命令行运行可执行文件。
Here is an example of a main function.:
这是一个主要功能的例子:
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
int main( int ac, char **av )
{
//--- Create the event manager and test controller
CPPUNIT_NS::TestResult controller;
//--- Add a listener that colllects test result
CPPUNIT_NS::TestResultCollector result;
controller.addListener( &result );
//--- Add a listener that print dots as test run.
CPPUNIT_NS::BriefTestProgressListener progress;
controller.addListener( &progress );
//--- Add the top suite to the test runner
CPPUNIT_NS::TestRunner runner;
runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
runner.run( controller );
return result.wasSuccessful() ? 0 : 1;
}
If you really want a GUI, there is QxRunner.
如果你真的想要一个GUI,那就有QxRunner。
#2
I would suggest people to use cppunit in visual studio if you are on windows and if you are testing for C++. How to configure cppunit in visual studio and how to use it with example? if you have downloaded the cppunit file. Then in your visual studio project you need to set few things
如果你在Windows上,如果你正在测试C ++,我建议人们在visual studio中使用cppunit。如何在visual studio中配置cppunit以及如何在示例中使用它?如果你已经下载了cppunit文件。然后在您的visual studio项目中,您需要设置一些东西
1). Give the path of include folder inside your cppunit file at location of your visual studio project, Project properties > C/C++ > General > Additional include directories.
1)。在Visual Studio项目的位置为cppunit文件提供include文件夹的路径,项目属性> C / C ++>常规>其他包含目录。
2). Give the path of lib folder inside your cppunit file at location of your visual studio project, Project properties > Linker > General > Additional library directories.
2)。在Visual Studio项目的位置为项目属性>链接器>常规>其他库目录提供cppunit文件中的lib文件夹路径。
3). Add a file "cppunit.lib" at location of your visual studio project, Project properties > Linker > Input > Additional Dependencies.
3)。在Visual Studio项目的位置添加文件“cppunit.lib”,项目属性>链接器>输入>附加依赖项。
Follow the step by step procedure in the link below
按照以下链接中的分步过程进行操作
http://www.areobots.com/unit-testing-with-cppunit-visual-studio-configuration/
http://www.areobots.com/how-to-do-unit-testing-with-cppunit-with-example/
#3
As mentioned in following link http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/checkout/sync4j/tools/cppunit/INSTALL-WIN32.txt?rev=1.1.1.1
如以下链接中所述http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/checkout/sync4j/tools/cppunit/INSTALL-WIN32.txt?rev=1.1.1.1
TestPlugInRunner can be used
可以使用TestPlugInRunner