打造第二代测试框架TestDriven 2.0(五)—— 测试框架初步展示

本文介绍了一个测试驱动框架的原型,该框架能够自动生成测试代码,并提供了单元测试案例。通过示例代码展示了如何进行单元测试及异常处理。

------------------ 

前言 Preface

------------------ 

本文是第二代测试框架系列文章,同时也是软件工程革命三部曲中的技术文献。

本文展示了测试驱动框架的原型,系统稳定后会放出源代码。

 

------------------ 

效果展示 Gallary

------------------ 

1. 自动生成测试代码

 

ExpandedBlockStart.gif代码

using  System;
using  System.Collections.Generic;
using  System.Text;
using  Pixysoft.TestDrivens;
using  Pixysoft.Framework.AutoUpdates;

namespace  Pixysoft.Framework.AutoUpdates.TestDrivens
{
    [TestDriven(TestDrivenType.UnitTest, 
" Pixysoft.Framework.AutoUpdates.Class1 " typeof (Pixysoft.Framework.AutoUpdates.Class1))]
    
class  UnitTest_000_Class1
    {
    
        [TestCase(
" hello " )]
        
public   static   void  TestCase_000_hello()
        {


        }




    }
}

 

 

2. 运行当前方法的单元测试:

 

ExpandedBlockStart.gif 代码
using  System;
using  System.Collections.Generic;
using  System.Text;
using  Pixysoft.TestDrivens;
using  Pixysoft.Framework.AutoUpdates;

namespace  Pixysoft.Framework.AutoUpdates.TestDrivens
{
    [TestDriven(TestDrivenType.UnitTest, 
" Pixysoft.Framework.AutoUpdates.Class1 " typeof (Pixysoft.Framework.AutoUpdates.Class1))]
    
class  UnitTest_000_Class1
    {

        [TestCase(
" hello " )]
        
public   static   void  TestCase_000_hello()
        {
            Assert.IsEqual(
" pixysoft " new  Class1().hello());
            Assert.IsEqual(
" hello " new  Class1().hello());
            
try
            {
                
throw   new  Exception( " test exception " );
            }
            
catch  (Exception ex)
            {
                LoggerHelper.Fatal(ex);
            }
        }
    }
}

 

 

3. 查看当前运行的日志

 

4. 升级测试代码

 

 

------------------ 

后记

------------------ 

基本功能都实现了,不过效果和易用性有待优化。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值