2010-12-15 34 views

回答

1

我剛剛跟NI的人談過話。

有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" 

使用theese包括報表應允許您運行這段代碼:

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 
1

我們還在這裏使用CUnit和CMock(ThrowTheStick)。隨着CVI你甚至可以自動化Ruby腳本在預先建立的步驟與somethine執行test_runner建設者像

"%RUBY_HOME%\bin\ruby.exe" "%UNITY_HOME%\auto\generate_test_runner.rb" 

Test_TestCycleFSM.c 。你可能需要編譯你的項目兩次才能生成源文件然後編譯它。

畢竟,庫尼特似乎是測試套件C.

+0

我有問題與CUNIT,但實際上你可以使用GTEST,並與周圍的extern「C」包裝導入C頭文件。所有你需要的是一個可以同時執行C和C++的編譯器。最後,我通過拋出CVI並使用VS2010解決了這個問題。 – Johannes 2012-12-04 11:46:19

+1

@Johannes:我已經(從字面上)懇求。但是我必須遵循CVI,而且它「沒有乾淨的構建」選項。 – Oliver 2012-12-04 12:21:51

+0

我聽到你的聲音。我仍然無法說服每個人。我的公司爲CVI付出了努力,甚至沒有使用它的「功能」。也許我們應該轉向程序員部分,並開始討論CVI中最糟糕的部分。 :) – Johannes 2012-12-04 15:47:57