首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >哪些测试框架可用于NI Lab Windows CVI?

哪些测试框架可用于NI Lab Windows CVI?
EN

Stack Overflow用户
提问于 2010-12-15 22:11:43
回答 2查看 906关注 0票数 1

我被迫使用NI Lab Windows CVI,我喜欢使用TDD。但是,我找不到该IDE的任何测试框架。有什么已知的解决方案吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-12-15 22:55:57

我刚和国家情报局的人谈过。

NI Lab View有一些完全不同的单元测试框架。

目前没有来自NI的解决方案。在过去,一些人使用TestComplete来解决他们的问题--另一种方法可能是使用CUnit

编辑:

在CVI中使用CUNIT真的很容易-尽管您仍然面临一些语言障碍:

代码语言:javascript
复制
#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语句应该允许您运行以下代码:

代码语言:javascript
复制
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;
}

还要将这些文件复制到您的结果目录中:

代码语言:javascript
复制
CUnit-List.dtd
CUnit-List.xsl
CUnit-Run.dtd
CUnit-Run.xsl
md2xml.pl
Memory-Dump.dtd
Memory-Dump.xsl
票数 1
EN

Stack Overflow用户

发布于 2012-12-04 17:27:18

我们在这里也使用带有CMock (ThrowTheStick)的CUnit。使用cvi,您甚至可以自动执行ruby脚本来执行test_runner构建器,例如

代码语言:javascript
复制
"%RUBY_HOME%\bin\ruby.exe" "%UNITY_HOME%\auto\generate_test_runner.rb"  

在您的预编译步骤中使用Test_TestCycleFSM.c。您可能需要编译项目两次才能生成源文件,然后再进行编译。

毕竟,CUnit似乎是C语言中的测试套件。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4450802

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档