博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
.net测试学习--理解.net测试选项
阅读量:7103 次
发布时间:2019-06-28

本文共 2124 字,大约阅读时间需要 7 分钟。

1.创建基于测试简单应用程序

   (1)启动visual studio(有安装c#的)

  (2)  选择File|New project

 (3)创建一个C# project,名字和保存路径自己设定,假设取名test1

(4)添加一个text控件和button控件

设置属性如下:

对象 属性 value
Button1 Test check
TextBox1 Text 空白

此时窗口如下:

(5) 双击设计器中的check按钮(之前添加的Button1)

添加如下代码:

 

if (textBox1.Text.Equals(""))          //if text is null  show message enter PATH                MessageBox.Show("Please enter your file PATH\n");                                            else                                   // check if your file is exists                            {                       if (File.Exists(textBox1.Text))                         MessageBox.Show(textBox1.Text + "\tis exists\n");                      else                         MessageBox.Show(textBox1.Text + "\tisn't exists\n");               }

(6)在代码文件开头添加,不要忘记在结尾加分号

Using System.IO;

此时代码结构如下:

(7)编译,debugging 或者使用F5

  如果没有错误,此时应该如下

         

(8) 测试

         a.不输入  会提示:Please enter your file PATH

   b. 输入不存在的路径 比如aa 输出aa isn't exists 反向测试

     c.输入c:\Windows\explorer.exe 输出 c:\Windows\explorer.exe is exists 正向测试

2.用控制台应用程序创建测试软件

控制台程序访问的三种基本数据流:标准输入,标准输出和标准错误

(1)创建工程 选择File|New Project,单击Console application,此时可以设置工程名字:test2

如图:

(2)添加代码

在开头添加 Using System.IO

在main函数内添加如下代码:

Console.WriteLine("***************************************************");            Console.WriteLine("Enter the file PATH,Enter Q/q to quit\n");            Console.WriteLine("***************************************************");            string strInput = "";            while (!strInput.ToUpper().Equals("Q")) //only if enter Q/q then quit            {                strInput = Console.ReadLine();          //read the command line and put into strInput                Console.WriteLine("your file name is:"+ strInput);                if (File.Exists(strInput))                {                    Console.WriteLine(strInput+" File Exists:Test PASS");                }                else                {                    Console.WriteLine(strInput + " File doesn't Exists:Test FAIL");                    Console.WriteLine("Enter the file PATH,Enter Q/q to quit\n");                 }              }

此时整体代码如下:

(3)运行 程序F5或者使用Debug

转载地址:http://bcchl.baihongyu.com/

你可能感兴趣的文章
关于Cocos2d-x的瓦片地图
查看>>
位置无关码
查看>>
find-k-pairs-with-smallest-sums
查看>>
情绪板携手视觉设计
查看>>
Atitit.php nginx页面空白 并返回500的解决
查看>>
http://blog.csdn.net/LANGXINLEN/article/details/50421988
查看>>
PHP高效率写法(详解原因)
查看>>
Swift 值类型/引用类型
查看>>
【WPF】点击滑动条(Slider),移动滑块(Tick)到鼠标点击的位置
查看>>
[每天五分钟,备战架构师-9]数据库系统
查看>>
[转]WinForm和WebForm下读取app.config web.config 中邮件配置的方法
查看>>
HDU-1903 Exchange Rates
查看>>
ado.net entity framework使用odp.net(ODAC for .net)连接oracle11g体验
查看>>
svn怎么版本还原?
查看>>
ABP源码分析三十七:ABP.Web.Api Script Proxy API
查看>>
Quartz 定时任务管理
查看>>
大公司都有哪些开源项目~~~简化版
查看>>
java生成word的完美解决方案
查看>>
ubuntu使用记录
查看>>
java生成zip压缩文件,解压缩文件
查看>>