利用VisualStudio白盒测试入门

现在越来越多的软件开发使用白盒测试了,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. 新建测试项目

利用VisualStudio白盒测试入门_第1张图片

    2. 在生成的UnitTest1.cs文件中修改代码,如图所示:

利用VisualStudio白盒测试入门_第2张图片

    这样我们写了2个测试方法TestMethod1(),TestMethod2(); 分别让其通过和不通过。

    3. 在实际的项目中,测试方法(Test Method)会非常多,为了方便管理,会建一些测试列表(Test List),如图所示:

利用VisualStudio白盒测试入门_第3张图片

    4. 忘了说了,Test Manager这个工作区是怎么显示出来的了。

先在菜单 View – Toolbars - Test Tools 中选中,让其显示测试工具条,然后在测试工具条上点击Test Manager按钮,请看下图。

利用VisualStudio白盒测试入门_第4张图片

    然后呢,如上图所示,先在Test Manager中选中要运行的Test Method,然后点击用红框标出的按钮,就可以运行选中的Test Method了。
    运行完之后,打开Test Result面板,就能看到运行的结果了,可以看到,我们写的Test Method,一个Passed了,一个Failed了。
    呵呵,白盒测试入门就是这么简单。

    下一篇文章在本文基础上写,请看

    使用脚本运行VisualStudio测试代码



你可能感兴趣的:(sql,server,Microsoft,测试,express,tools,macros)