我被迫使用NI Lab Windows CVI,我喜欢使用TDD。但是,我找不到该IDE的任何测试框架。有什么已知的解决方案吗?
发布于 2010-12-15 22:55:57
我刚和国家情报局的人谈过。
NI Lab View有一些完全不同的单元测试框架。
目前没有来自NI的解决方案。在过去,一些人使用TestComplete来解决他们的问题--另一种方法可能是使用CUnit。
编辑:
在CVI中使用CUNIT真的很容易-尽管您仍然面临一些语言障碍:
#include "CUError.h"
#include "CUError.c"
#include "CUnit.h"
#include "MyMem.h"
#include "MyMem.c"
#include "TestDB.h"
#include "TestDB.c"
#include "TestRun.h"
#include "TestRun.c"
#include "Util.h"
#include "Util.c"
#include "Automated.h"
#include "Automated.c"使用这些include语句应该允许您运行以下代码:
static void testFail(void)
{
CU_ASSERT(0);
}
//Suite Definitions
static CU_TestInfo tests_GenList[] = {
{ "Should Fail", testFail },
CU_TEST_INFO_NULL,
};
static CU_SuiteInfo suites[] = {
{ "Generic List Suites", NULL, NULL, tests_GenList },
CU_SUITE_INFO_NULL,
};
void AddTests(void)
{
assert(NULL != CU_get_registry());
assert(!CU_is_test_running());
/* Register suites. */
if (CU_register_suites(suites) != CUE_SUCCESS) {
fprintf(stderr, "suite registration failed - %s\n",
CU_get_error_msg());
exit(EXIT_FAILURE);
}
}
int main (void)
{
CU_initialize_registry();
AddTests();
CU_set_output_filename("Result\\TestAutomated");
CU_list_tests_to_file();
CU_automated_run_tests();
CU_cleanup_registry();
return 0;
}还要将这些文件复制到您的结果目录中:
CUnit-List.dtd
CUnit-List.xsl
CUnit-Run.dtd
CUnit-Run.xsl
md2xml.pl
Memory-Dump.dtd
Memory-Dump.xsl发布于 2012-12-04 17:27:18
我们在这里也使用带有CMock (ThrowTheStick)的CUnit。使用cvi,您甚至可以自动执行ruby脚本来执行test_runner构建器,例如
"%RUBY_HOME%\bin\ruby.exe" "%UNITY_HOME%\auto\generate_test_runner.rb" 在您的预编译步骤中使用Test_TestCycleFSM.c。您可能需要编译项目两次才能生成源文件,然后再进行编译。
毕竟,CUnit似乎是C语言中的测试套件。
https://stackoverflow.com/questions/4450802
复制相似问题