不确定你究竟在问什么,但你可以轻松编写自己的自定义属性来做到这一点.举个例子..
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class TraceAttribute : BeforeAfterTestAttribute
{
public override void Before(MethodInfo methodUnderTest)
{
//Start timer
}
public override void After(MethodInfo methodUnderTest)
{
//End timer
}
}
Run Code Online (Sandbox Code Playgroud)
然后用this属性装饰你的单元测试.还要确保写入输出;)
| 归档时间: |
|
| 查看次数: |
2128 次 |
| 最近记录: |