中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

php網(wǎng)站開發(fā)需要學什么怎么宣傳自己新開的店鋪

php網(wǎng)站開發(fā)需要學什么,怎么宣傳自己新開的店鋪,下載別人網(wǎng)站的asp,公司常用網(wǎng)站開發(fā)軟件Unity簡介: Unity是一個用于C語言的輕量級單元測試框架。它由Throw The Switch團隊開發(fā),旨在簡化嵌入式系統(tǒng)的單元測試。單元測試中單元的含義,單元就是人為規(guī)定的最小的被測功能模塊,如C語言中單元指一個函數(shù),Java里…

Unity簡介:

Unity是一個用于C語言的輕量級單元測試框架。它由Throw The Switch團隊開發(fā),旨在簡化嵌入式系統(tǒng)的單元測試。單元測試中單元的含義,單元就是人為規(guī)定的最小的被測功能模塊,如C語言中單元指一個函數(shù),Java里單元指一個類,圖形化的軟件中可以指一個窗口或一個菜單等。在實際項目中,單元測試往往由開發(fā)人員完成。
Unity的設(shè)計目標是易于使用、輕便、可移植,并能夠在各種嵌入式和非嵌入式系統(tǒng)中運行。核心項目是一個 C 文件和一對頭文件,允許將其添加到現(xiàn)有的構(gòu)建設(shè)置中,而不會太麻煩。 可以使用任何想用的編譯器,并且可以使用大多數(shù)現(xiàn)有的構(gòu)建系統(tǒng),包括 Make、CMake 等。

Unity簡單使用方法:

1、下載unity框架

去GitHub下載,或者gti clone到本地,鏈接地址:unity。

Unity 本身非常小。 其他剩下的只是可選附加組件。 可以忽略它或在方便時使用它。 以下是項目中所有內(nèi)容的概述。

  • src- 這是你關(guān)心的代碼!此文件夾包含一個 C 文件和兩個頭文件。 這三個文件是 Unity。
  • docs- 在這里可以找到所有方便的文檔。
  • examples- 這包含一些使用 Unity 的示例。
  • extras- 這些是 Unity 的可選附加組件,不屬于核心項目。
  • test- 這就是 Unity 及其腳本的測試方式。 如果你只是使用Unity,你可能永遠不需要進入這里。
  • auto- 在這里,你將找到有用的 Ruby 腳本,以簡化你的測試工作流程。 它們完全是可選的,不需要使用 Unity。

2、使用unity框架

測試文件是 C 文件。 大多數(shù)情況下,將為每個要測試的 C 模塊創(chuàng)建一個測試文件。 測試文件應包含 unity.h 和要測試的 C 模塊的標頭。

例如測試下面兩個函數(shù):

ProductionCode.c

#include "ProductionCode.h"int Counter = 0;
int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; /* some obnoxious array to search that is 1-based indexing instead of 0. *//* This function is supposed to search through NumbersToFind and find a particular number.* If it finds it, the index is returned.  Otherwise 0 is returned which sorta makes sense since* NumbersToFind is indexed from 1.  Unfortunately it's broken* (and should therefore be caught by our tests) */
int FindFunction_WhichIsBroken(int NumberToFind)
{int i = 0;while (i < 8) /* Notice I should have been in braces */i++;if (NumbersToFind[i] == NumberToFind) /* Yikes!  I'm getting run after the loop finishes instead of during it! */return i;return 0;
}int FunctionWhichReturnsLocalVariable(void)
{return Counter;
}

ProductionCode.h

#ifndef  _PRODICTIONCODE_H_
#define  _PRODICTIONCODE_H_extern int Counter;int FindFunction_WhichIsBroken(int NumberToFind);
int FunctionWhichReturnsLocalVariable(void);#endif

接下來,測試文件將包含測試例程函數(shù)。 setUp 函數(shù)可以包含你希望在每次測試之前運行的任何內(nèi)容。 tearDown 函數(shù)可以包含你希望在每次測試后運行的任何內(nèi)容。 這兩個函數(shù)都不接受任何參數(shù),也不返回任何內(nèi)容。 如果不需要它們,將其設(shè)置為空。setUp() tearDown()

TestProductionCode.h


#include "ProductionCode.h"
#include "unity.h"/* sometimes you may want to get at local data in a module.* for example: If you plan to pass by reference, this could be useful* however, it should often be avoided */
extern int Counter;void setUp(void)
{/* This is run before EACH TEST */Counter = 0x5a5a;
}void tearDown(void)
{
}void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void)
{/* All of these should pass */TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78));TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(2));TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33));TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(999));TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(-1));
}void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void)
{/* You should see this line fail in your test summary */TEST_ASSERT_EQUAL(1, FindFunction_WhichIsBroken(34));/* Notice the rest of these didn't get a chance to run because the line above failed.* Unit tests abort each test function on the first sign of trouble.* Then NEXT test function runs as normal. */TEST_ASSERT_EQUAL(8, FindFunction_WhichIsBroken(8888));
}void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void)
{/* This should be true because setUp set this up for us before this test */TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable());/* This should be true because we can still change our answer */Counter = 0x1234;TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable());
}void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void)
{/* This should be true again because setup was rerun before this test (and after we changed it to 0x1234) */TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable());
}void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void)
{/* Sometimes you get the test wrong.  When that happens, you get a failure too... and a quick look should tell* you what actually happened...which in this case was a failure to setup the initial condition. */TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable());
}

最后,在編寫main函數(shù),然后調(diào)用每個測試例程函數(shù)。 這實際上會觸發(fā)每個測試例程函數(shù)運行,因此每個函數(shù)都有自己的調(diào)用非常重要。

/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
#include "ProductionCode.h"/*=======External Functions This Runner Calls=====*/
extern void setUp(void);
extern void tearDown(void);
extern void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void);
extern void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void);
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void);
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void);
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void);/*=======MAIN=====*/
int main(void)
{UnityBegin("test/TestProductionCode.c");RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode);RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken);RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue);RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain);RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed);return (UnityEnd());
}

3、構(gòu)建運行環(huán)境

創(chuàng)建一個目錄 TDDUnityExample,在TDDUnityExample 目錄下創(chuàng)建 CMakeLists.txt 文件。

# 最低CMake版本要求
cmake_minimum_required(VERSION 3.15)#將Unity/src工作目錄的源文件賦給UNITY_SRC_LIST
#將Tests工作目錄的源文件賦給APP_SRC_DIR
aux_source_directory (Unity/src UNITY_SRC_LIST)
aux_source_directory (Tests APP_SRC_DIR)# 項目名稱
project(TDD_test)# 頭文件路徑
include_directories(Unity/src)#將所有源文件生成一個可執(zhí)行文件
add_executable(TDD_test  ${APP_SRC_DIR} ${UNITY_SRC_LIST})
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

在 TDDUnityExample 下創(chuàng)建 Unity 目錄,然后將Unity 框架源碼中的 src 目錄拷貝到 Unity目錄中。

在 TDDUnityExample 下創(chuàng)建 Tests 目錄,然后將第二點中舉例的測試文件都放在 Tests 目錄中。

在 TDDUnityExample 下創(chuàng)建 build 目錄,然后在 build 目錄下也創(chuàng)建一個 CMakeLists.txt 文件。

cmake_minimum_required (VERSION 2.8)project (TDD_test)add_subdirectory (Tests)

最后整體文件結(jié)構(gòu)如下:

├── build
│   └── CMakeLists.txt
├── CMakeLists.txt
├── Tests
│   ├── ProductionCode.c
│   ├── ProductionCode.h
│   ├── TestProductionCode.c
│   └── TestProductionCode_Runner.c
└── Unity└── src├── meson.build├── unity.c├── unity.h└── unity_internals.h

4、運行測試程序

在 build 目錄下輸入 cmake ..命令,會自動生成 Makefile 文件,然后輸入make,就會自動編譯生成可執(zhí)行文件 TDD_test 在 TDDUnityExample /bin 下。

進入 TDDUnityExample /bin 下,輸入./TDD_test。

輸出結(jié)果為:

test/TestProductionCode.c:0:test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode:PASS
test/TestProductionCode.c:33:test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken:FAIL: Expected 1 Was 0
test/TestProductionCode.c:0:test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue:PASS
test/TestProductionCode.c:0:test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain:PASS
test/TestProductionCode.c:61:test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed:FAIL: Expected 0x00001234 Was 0x00005A5A-----------------------
5 Tests 2 Failures 0 Ignored 
FAIL

從結(jié)果來看第二個和第五個測試例程出現(xiàn)錯誤,錯誤原因也標記出來了。

5、常用斷言

TEST_PASS(); /* 中止測試的其余部分, 但將測試計為通過 */
TEST_PASS_MESSAGE("message")TEST_IGNORE(); /* 將測試用例標記為忽略, 但將測試計為通過 */
TEST_PASS_MESSAGE("message")TEST_FAIL(); /* 中止測試的其余部分, 但將測試計為失敗 */
TEST_FAIL_MESSAGE("message")TEST_MESSAGE(""); /* 將消息輸出 */

以上斷言宏都是放在編寫的測試函數(shù)中,TEST_IGNORE 一般放在函數(shù)的頂部,用來表示將測試用例忽略,其他宏可以放在函數(shù)的任意位置。

總結(jié):

unity單元測試框架核心是一個 C 文件和一對頭文件,特點是簡潔易用、輕量級、可移植性、支持測試斷言等。其中有許多測試斷言需要多了解多使用。

好了以上就是Unity單元測試框架的簡易使用方法,有什么疑問和建議歡迎在評論區(qū)中提出,想要了解更多的Unity知識可以去官網(wǎng)上查看,官網(wǎng)上也有詳細的教程和實例。

http://m.risenshineclean.com/news/61320.html

相關(guān)文章:

  • 網(wǎng)站開發(fā)績效考核站長工具友鏈檢測
  • 泰安的網(wǎng)站建設(shè)公司哪家好正規(guī)推廣平臺
  • 購物網(wǎng)站開發(fā)的需求分析常見的網(wǎng)站推廣方式
  • 做網(wǎng)站建設(shè)公司crm在線的提升服務外貿(mào)網(wǎng)站推廣服務
  • 上海建設(shè)電動車網(wǎng)絡營銷鄭州優(yōu)化推廣公司
  • 課程網(wǎng)站建設(shè) 碧輝騰樂谷歌seo
  • 網(wǎng)絡營銷策劃是什么意思seo排名優(yōu)化方法
  • 蘇州怎么制作網(wǎng)頁網(wǎng)站杭州網(wǎng)站seo價格
  • 廣東哪里網(wǎng)站建設(shè)安卓優(yōu)化神器
  • seopc流量排名官網(wǎng)超級seo外鏈
  • 免費個人crmapp網(wǎng)站優(yōu)化排名易下拉穩(wěn)定
  • 外貿(mào)狼成都seo的方法
  • 做線下活動的網(wǎng)站武漢seo網(wǎng)絡優(yōu)化公司
  • 云南酒店網(wǎng)站建設(shè)名優(yōu)網(wǎng)站關(guān)鍵詞優(yōu)化
  • 小游戲網(wǎng)址鏈接seo網(wǎng)站推廣優(yōu)化論文
  • java做直播網(wǎng)站有哪些軟件有哪些微信加人推碼35一單
  • 商務網(wǎng)站建設(shè)管理思路青島seo經(jīng)理
  • 做的網(wǎng)站怎么發(fā)布到網(wǎng)上網(wǎng)絡推廣方案怎么寫
  • 模仿網(wǎng)站怎么防止侵權(quán)電商關(guān)鍵詞一般用哪些工具
  • icp備案網(wǎng)站要先建好嗎微信社群營銷
  • 北京網(wǎng)站建設(shè)價格天湛江今日頭條新聞
  • 鄭州網(wǎng)站的優(yōu)化廣州公關(guān)公司
  • 網(wǎng)站建設(shè)外包排名游戲推廣在哪里接活
  • app網(wǎng)站制作要多少錢排名nba
  • 做電影網(wǎng)站的工具抖音關(guān)鍵詞搜索排名
  • 做網(wǎng)站最主要搜索引擎推廣的費用
  • 政府網(wǎng)站建設(shè)辦法中國工商業(yè)聯(lián)合會
  • 如何通過建設(shè)網(wǎng)站賺錢天津疫情最新情況
  • 什么網(wǎng)站可以做相冊城關(guān)網(wǎng)站seo
  • 25轉(zhuǎn)行做網(wǎng)站運營優(yōu)化搜狗排名