苯苯的博客

新随笔 联系 管理
  21 Posts :: 0 Stories :: 3 Comments :: 0 Trackbacks

2008年8月11日 #

 

 public static string GetCaseMethodName()
        
{
            
try
            
{
                StackTrace st 
= new StackTrace();
                StackFrame[] stackFrames 
= st.GetFrames();
                
foreach (StackFrame sf in stackFrames)
                
{
                    MethodBase mb 
= sf.GetMethod();
                    
if (mb.GetCustomAttributes(typeof(TestMethodAttribute), false).Length > 0)
                        
return mb.Name;
                }

                
return string.Empty;
            }

            
catch throw; }
        }
posted @ 2008-08-11 03:50 one 阅读(8) | 评论 (0)编辑