zoukankan      html  css  js  c++  java
  • 第一次用NUnitAsp

    写的第一个NUnitAsp测试程序,是看着自带的帮助作的。

    在WebForm上放一个TextBox和Button,测试类如下:
    在项目中添加对NUnitAsp.dll的引用,再引用命名空间:
    using NUnit.Framework;
    using NUnit.Extensions.Asp;
    using NUnit.Extensions.Asp.AspTester;

    [TestFixture]
        
    public class xxx :NUnit.Extensions.Asp.WebFormTestCase
        
    {
            
    const string myPage = @"http://localhost/WebApplication6/WebForm1.aspx";
            ButtonTester bt;
            TextBoxTester text;
            
    protected override void SetUp()
            
    {
                Browser.GetPage(myPage);
                bt 
    = new ButtonTester("Button1",CurrentWebForm);
                text 
    = new TextBoxTester("TextBox1",CurrentWebForm);
            }


            
    protected override void TearDown()
            
    {
            }

            
            [Test]
            
    public void TestButton()
            
    {
                NUnit.Extensions.Asp.WebAssertion.AssertVisibility(bt ,
    true);
            }

            
    public void TestText1()
            
    {
                text.Text 
    = "aaa";
                bt.Click();
                NUnit.Extensions.Asp.WebAssertion.AssertEquals(text.Text ,
    "aaa");
            }

        }

    打开NUnit运行测试,打开程序集,运行测试。看着绿色的进度条闪过,感觉真好
    不过感觉要是界面上的东西多了,测试恐怕还是会有点麻烦。
    刚开始学习,还请大家多多指教


  • 相关阅读:
    表单的编辑添加和删除 .removeClass() .append() .preAll() .attr('b') document.createElement()
    菜单与内容下拉jQuery
    s2选择框的全选和反选jQuery
    作用域
    当前触发事件的两种方式(onclick) 和 ('id') 获取
    词义分析
    Qt下载地址
    字符集(编码)转换_Qt532_QString
    字符集(编码)转换_Windows
    字符集(编码)转换_Linux
  • 原文地址:https://www.cnblogs.com/dahuzizyd/p/24917.html
Copyright © 2011-2022 走看看