chiname

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

体验Vs2005 beta2 测试工具

体验Vs2005 beta2 测试工具

    在Vs2005中加入了单元测试工具,使用与NUnit差不多。但功能更加丰富了,而且使用更加方便,有利于项目的协调工作。而且还支持调试测试,(不知道NUnit支不支持,我是没用过。)方便我们调试出错代码。
    Vs2005 Test tool 与NUnit 特性类对应
            NUnit                                                Vs2005 Tools
     NUnit.Framework            Microsoft.VisualStudio.QualityTools.UnitTesting.Framework
     TestFixtureAttribute                   TestClassAttribute
    TestFixtureSetUpAttribute            ClassInitializeAttribute
    TestFixtureTearDownAttribute       ClassCleanupAttribute
    SetUpAttribute                                TestInitializeAttribute   
     TearDownAttribute                        TestCleanupAttribute
    
    创建一个测试工程。
    打开UnitTest1.cs  它已经为我们生成了一个测试的Sample框架了.

[TestClass]
    
public class UnitTest1
    
{
        
public UnitTest1()
      
{
            
//
            
// TODO: Add constructor logic here
            
//
        }


        
/// <summary>
        
/// Initialize() is called once during test execution before
        
/// test methods in this test class are executed.
        
/// </summary>

        [TestInitialize()]
        
public void Initialize()
      
{
            
//  TODO: Add test initialization code
        }


        
/// <summary>
        
/// Cleanup() is called once during test execution after
        
/// test methods in this class have executed unless the
        
/// corresponding Initialize() call threw an exception.
        
/// </summary>

        [TestCleanup()]
        
public void Cleanup()
      
{
            
//  TODO: Add test cleanup code
        }


        [TestMethod]
        
public void TestMethod1()
      
{
            Assert.IsTrue(
true,"this is work");
        }

    }

    熟悉NUnit的一眼就会明白那些Attribute是干嘛用的了。在里面写了一句简单的断言语句。这样就是一个简单的测试实例了。
    接下来运行这个测试实例。找到Test菜单项,选择"Manage and Execute Tests。在这管理器里面可以选择在项目中已经存在的测试实例。并选择是否运行测试。

 
    单击"By Test List"右边那上工具栏按钮。就开始执行测试了。查看测试结果
双击可以看到详细信息。
    刚才说到的还可以断点调试。很简单,只需要在测试实例设置断点,然后点击刚才的运行按扭的下拉框,可以看到有“Debug Checked tests”。这样就可以调试了。很方便!

    就这么简单!

posted on 2005-09-22 10:24 阿不 阅读(1760) 评论(9)  编辑 收藏 收藏至365Key 所属分类: .NET 2.0 && VS2005

评论

# re: 体验Vs2005 beta2 测试工具 2005-09-22 11:05 CsOver

微软的脚步太快了,有点跟不上了.:(  回复   

# re: 体验Vs2005 beta2 测试工具 2005-09-22 13:01 Cavingdeep

@CsOver

这还叫快?!  回复   

# re: 体验Vs2005 beta2 测试工具 2005-09-22 16:17 Pvistely

这个测试工具以前在MS的视频上看他们搞过,
不过那时候看的是一个WEB的测试.....
还不是很了解..哪能下载?呼呼~~~~  回复   

# re: 体验Vs2005 beta2 测试工具 2005-09-22 16:26 §猪阿不猪§

集成在Vs2005里面了.  回复   

# re: 体验Vs2005 beta2 测试工具 2005-09-22 17:09 商务之窗

收藏  回复   

# re: 体验Vs2005 beta2 测试工具 2005-09-24 09:25 liubiqu

下一个项目考虑用测试驱动来进行试试看。现在的人做项目对测试没有感觉的。特别是单元测试,可能是都太自信了吧,呵呵。  回复   

# re: 体验Vs2005 beta2 测试工具 2005-09-29 21:07 深渊野鱼

曾经尝试过,但是太慢:(
呵呵,自己的机器比较滥,所以后来还是继续nunit.  回复   

# re: 体验Vs2005 beta2 测试工具 2006-07-05 17:43 applezhang

@Pvistely
谁能告诉我,怎么样进行web 测试,谢谢了  回复   

# re: 体验Vs2005 beta2 测试工具 2006-07-05 17:44 applezhang

我的MSN 是bennydfs@163.com  回复   

posted on 2006-07-07 09:17  把我的欢乐带给你  阅读(164)  评论(0)    收藏  举报