I am forced to use NI Lab Windows CVI, and i would love work with TDD. However i could not find any testframeworks开发者_StackOverflow中文版 for that IDE. Are there any known solutions?
I just talked to someone at NI.
There are Unit Test Frameworks for NI Lab View wich is something completely different.
There is currently no solution from NI. In the past some people solved their issues using TestComplete - another route might be using CUnit.
EDIT:
Using CUNIT with CVI is really easy - though you still face some language Barriers:
#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"
Using theese include statements should allow you to run this code:
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;
}
Also copy these files into your Result directory:
CUnit-List.dtd
CUnit-List.xsl
CUnit-Run.dtd
CUnit-Run.xsl
md2xml.pl
Memory-Dump.dtd
Memory-Dump.xsl
We also use CUnit with CMock (ThrowTheStick) over here. With cvi you can even automate the ruby scripts to execute the test_runner builder with somethine like
"%RUBY_HOME%\bin\ruby.exe" "%UNITY_HOME%\auto\generate_test_runner.rb"
Test_TestCycleFSM.c in your pre-build steps. You maybe have to compile your project twice to generate the sourcefile and compile it then.
After all, CUnit seems to be the tests suite in C.
精彩评论