zoukankan      html  css  js  c++  java
  • .net测试学习--理解.net测试选项

    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
    ");                     
               
                else                                   // check if your file is exists
                   
                 {     
                      if (File.Exists(textBox1.Text))
                             MessageBox.Show(textBox1.Text + "	is exists
    ");
                          else
                             MessageBox.Show(textBox1.Text + "	isn't exists
    ");
    }


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

    Using System.IO;

    此时代码结构如下:

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

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

             

    (8) 测试

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

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

         c.输入c:Windowsexplorer.exe 输出 c:Windowsexplorer.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
    ");
                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
    ");
    }
    }

    此时整体代码如下:

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

  • 相关阅读:
    转载:@Html.ValidationSummary(true)
    转载:SQL中Group By 的常见使用方法
    转载:SQL按照日、周、月、年统计数据的方法
    级联删除
    视图是什么?
    数据冗余与外键
    源码网站汇总(转载)
    SQL语句的增删改查(详细)--转载
    Map的四种遍历方式
    HBase表预分区
  • 原文地址:https://www.cnblogs.com/tobecrazy/p/3285458.html
Copyright © 2011-2022 走看看