.NET软件测试指南

上一篇 / 下一篇  2008-11-18 23:45:22 / 个人分类:.NET软件测试指南

2理解.NET测试选项

 

2.1用于测试的.NET命名空间

测试人员必须完成的一个重要的工作是,查找并返回如下信息:应用程序在运行时的信息、系统在运行应用程序之前、之后和运行过程中的状态信息。要想学习如何获取重要的系统信息,首先要理解如何使用.NET命名空间。

用于测试的一些重要的命名空间有下面几个:

l        System.IO

l        System.Data

l        System.Text.RegularExpressions

l        Microsoft.Win32

l        System.Web

l        Microsoft.VisualStudio.TestTools

l        Microsoft.VisualBasic

l        System.Diagnostics

在后面将作详细解释。

打开Visual Studio.NETView->Object Browser中可以看到一些命名空间,以及包含用于测试的例程。

2.2使用System.IO命名空间中的Exists函数

Exists可以判断文件是否存在。被测的应用程序在运行期间常常会创建文件,包括永久文件和临时文件,因此可以用Exists函数来确定应用程序运行时是否创建或删除了适当的文件。

例:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Text;

usingSystem.Windows.Forms;

usingSystem.IO;

 

namespacefirsttest

{

   publicpartialclassForm1:Form

   {

       publicForm1()

       {

           InitializeComponent();

       }

 

       privatevoidbutton1_Click(objectsender,EventArgse)

       {

           if(File.Exists(textBox1.Text))

               MessageBox.Show("File Exists:Test passed");

           else

               MessageBox.Show("File doesn't Exists:Test failure");

       }

   }

}

 


TAG: 测试知识

引用 删除 yinyifei   /   2009-07-22 15:47:37
5
 

评分:0

我来说两句

Open Toolbar