現在越來越多的軟體開發使用白盒測試了,C++有CppUnit,.Net有NUnit, 在VisualStudio中也給我們提供了一套測試架構,但是該測試架構似乎只有在VS某幾個版本才有。
那麼VisualStudio有哪些版本呢?以VisualStudio2005來看,他有些什麼版本呢?各個版本有些什麼區別呢?
請參考網頁:
http://msdn.microsoft.com/en-us/vstudio/aa700921.aspx
下表是從該網頁中拷貝出來的。即Visual Studio 2005產品線一覽圖。
Visual Studio 2005 Product Line Overview
Feature |
Express Products |
Visual Studio Standard Edition |
Visual Studio Professional Edition |
Visual Studio Tools For Office |
Visual Studio Team System |
IntelliSense |
Yes |
Yes |
Yes |
Yes |
Yes |
Code editor |
Yes |
Yes |
Yes |
Yes |
Yes |
Code snippets |
Yes |
Yes |
Yes |
Yes |
Yes |
Programming languages included |
VB, VC#, VC++, and VJ# are single language. Visual Weincludes VC# and VB |
All |
All |
VB and VC# |
All |
Office development support* |
No |
No |
No |
Support for Excel 2003, Word 2003, InfoPath 2003 2003 |
Support for Excel 2003, Word 2003, InfoPath 2003 2003 |
User experience |
Simplified menu options and defaults |
Simplified menu options and defaults |
Full |
Full |
Full |
Windows Forms designer |
VB, VC#, VC++, VJ# |
Yes |
Yes |
Yes |
Yes |
Web Forms designer |
Visual Web Developer |
Yes |
Yes |
Yes |
Yes |
Mobile Device Support* |
No |
Yes |
Yes |
No |
Yes |
Database design tools (create/modify tablesprocedures) |
Local |
Local and remote |
Local and remote |
Local and remote |
Local and remote |
Data Access Designers |
VB, VC#, VC++, VJ#:local, Visual Web Developer: local |
Local and remote |
Local and remote |
Local and remote |
Local and remote |
Documentation |
10mb "Getting Started"; Starter Kitfirst-time programmers; 200mb optional MSDN Express |
MSDN |
MSDN |
MSDN |
MSDN |
Class Designer / Object Test Bench* |
No |
Yes |
Yes |
Yes |
Yes |
XML Editor Support |
XML Only |
XML Only |
Full XML/XSLT |
Full XML/XSLT |
Full XML/XSLT |
Deployment Tools |
ClickOnce |
Yes |
Yes |
Yes |
Yes |
Extensibility |
Use 3rd party controls and content. No Macros,Packages |
Write, record, run macros, Write and consume Add-iPackages (partner products) |
Write, record, run macros, Write and consume Add-iPackages (partner products) |
Write, record, run macros, Write and consume Add-iPackages (partner products) |
Write, record, run macros, Write and consume Add-iPackages (partner products) |
Reporting |
Visual Web Developer: SQL Server Reporting Services Add-in |
SQL Server Reporting Services |
SQL Server Reporting Services / Crystal Reports |
SQL Server Reporting Services |
SQL Server Reporting Services / Crystal Reports |
Source Code Control |
No |
MSSCCI-compatible (Visual SourceSafe sold separately) |
MSSCCI-compatible (Visual SourceSafe sold separately) |
MSSCCI-compatible (Visual SourceSafe sold separately) |
MSSCCI-compatible (includes Visual SourceSafe, ViTeam Foundation Server sold separately) |
Debugging |
Local |
Local |
Local / remote |
Local |
Local / remote |
64-bit Compiler Support (Itanium) |
No |
No |
No |
No |
Yes |
64-bit Compiler Support (x64) |
No |
Yes |
Yes |
No |
Yes |
Server explorer |
No |
No |
All |
All |
All |
SQL Server 2005 Integration |
No |
No |
Yes |
Yes |
Yes |
Code Profiling |
No |
No |
No |
No |
Yes |
Static Analysis |
No |
No |
No |
No |
Yes |
Unit Testing* |
No |
No |
No |
No |
Yes |
Code Coverage |
No |
No |
No |
No |
Yes |
Project Management |
No |
No |
No |
No |
Yes |
Test Case Management |
No |
No |
No |
No |
Yes |
Offline Database Project |
No |
No |
No |
No |
Yes |
Data Generation |
No |
No |
No |
No |
Yes |
Database Refactoring |
No |
No |
No |
No |
Yes |
Database Schema and Data Compare |
No |
No |
No |
No |
Yes |
Database Deployment Tools |
No |
No |
No |
No |
Yes |
Size |
80mb (Express + SQL Express + .NET Framework Redist) |
Multiple CDs |
Multiple CDs |
Multiple CDs |
Multiple CDs |
Additional Tools Included |
SQL Server 2005 Express Edition |
SQL Server 2005 Express Edition |
SQL Server 2005 Developer Edition |
SQL Server 2005 Developer Edition; Microsoft Office Developer Extensions; Access 2003 Runtime license |
SQL Server 2005 Developer Edition (included with clieonly) |
簡單來說,我們可以歸納一下:
Express---試用版
Pro---全稱是Visual Studio 2005 Professional Edition,是適合小規模使用的版本,授權8-10個人左右。
Std---全稱是Visual Studio Standard Edition,也是授權版本,比Pro多一些;
VSTO---Visual Studio 2005 Tools for the Microsoft Office System,對office系列產品進行開發;
VSTS---Visual Studio 2005 Team System,也是針對軟體開發的各個層次最全面的一個版本
可以看到,這幾個版本中,只有VSTS有Unit Test的功能。所以要想利用VisualStudio來做白盒測試,必須安裝VSTS,其他版本都沒有。
安裝完VSTS後,開始寫白盒測試代碼吧。一步一步做吧:
1.建立測試專案
2.在產生的UnitTest1.cs檔案中修改代碼,:
這樣我們寫了2個測試方法TestMethod1(),TestMethod2(); 分別讓其通過和不通過。
3.在實際的項目中,測試方法(Test Method)會非常多,為了方便管理,會建一些測試清單(Test List),:
4.忘了說了,Test Manager這個工作區是怎麼顯示出來的了。
先在菜單 View – Toolbars - Test Tools 中選中,讓其顯示測試載入器條,然後在測試載入器條上點擊Test Manager按鈕,請看。
然後呢,如所示,先在Test Manager中選中要啟動並執行Test Method,然後點擊用紅框標出的按鈕,就可以運行選中的Test Method了。
運行完之後,開啟Test Result面板,就能看到啟動並執行結果了,可以看到,我們寫的Test Method,一個Passed了,一個Failed了。
呵呵,白盒測試入門就是這麼簡單。
下一篇文章在本文基礎上寫,請看
使用指令碼運行VisualStudio測試代碼