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

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

前言 Preface

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

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

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

 

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

效果展示 Gallary

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

1. 自动生成测试代码

 

代码

复制代码
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. 运行当前方法的单元测试:

 

复制代码
代码
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. 升级测试代码

 

 

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

后记

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

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

posted @     阅读(387)  评论(1编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· [AI/GPT/综述] AI Agent的设计模式综述
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
IT民工
点击右上角即可分享
微信分享提示