2013年7月29日 星期一

[W8App] VS2012 Unit Test – Prepare environment (1)

VS2012已能建立Windows Store Unit Test Library,但是C++ WinRT卻無法測試async函式。Win8 app和傳統的Desktop app最大的一個不同點是非同步(async)的架構,Async在某些類別的API幾乎是標準設計了。因此若有開發Windows Store Unit Test計畫的話,建議在安裝完VS2012之後先安裝C++ WinRT Async UnitTestLibrary。除了從網路上下載外,也可直接從VS2012的選單[TOOLS] –> [Extensions and Updates]中找到這個擴充套件。

WinRT Async

安裝完成後,VS2012會多一個專案選項[Unit Test Library with Async Helper (Windows Store apps)]。若測試的函式有包含非同步架構的話,就必需選用這個專案範本。

Add WinRT Async

* C++ WinRT Async UnitTestLibrary是MS開發團隊在開發著名的範例程式Hilo的過程中所開發出來的Unit Test套件,原始程式碼在C++ Unit Test Library for Windows Store apps with Async Helper有與趣可自行參考。