codedui中的方法名称 [英] method name in codedui

查看:92
本文介绍了codedui中的方法名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


任何人都可以帮助我,我使用下面的代码来获取CodedUI中的总方法数
private int CountNumberOfTestMethods()

{

    int countOfTestMethods = 0;


    foreach(System.Reflection.Assembly.GetExecutingAssembly()中的类型ty。GetTypes())

    {

        foreach(ty.GetMethods()中的System.Reflection.MethodInfo方法)

        {

           的foreach(在method.CustomAttributes System.Reflection.CustomAttributeData CA)

            {

               如果(ca.ToString()==" [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]")

       &NBSP ;        {

                    countOfTestMethods ++;

                }
            }
        }
    }


    return countOfTestMethods;

}



谢谢我已经成功,就像我现在创建的类库一样上面的代码,并在我的encodeui脚本中使用作为参考,我 能够获得totalmethods,但我们如何在codeduiscript中获得每个METHODE名称?为例如:在提前(enterusername)


由于

解决方案

只需使用"姓名" ; "方法"的字段上面的变量。

 string theName = method.Name; 
Console.WriteLine("方法的名称是" + theName);

问候


Adrian


Hi

can any one help me i have used below code to get total metods in CodedUI
private int CountNumberOfTestMethods()
{
    int countOfTestMethods = 0;

    foreach (Type ty in System.Reflection.Assembly.GetExecutingAssembly().GetTypes())
    {
        foreach (System.Reflection.MethodInfo method in ty.GetMethods())
        {
            foreach (System.Reflection.CustomAttributeData ca in method.CustomAttributes)
            {
                if ( ca.ToString() == "[Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]" )
                {
                    countOfTestMethods++;
                }
            }
        }
    }

    return countOfTestMethods;
}

Thanks I have got successfully, the same like I have now created classlibrary for the above code and using as refrence in my codedui script, I  able to get totalmethods ,but how can we get each METHODE Name in codeduiscript? for eg:(enterusername)

Thanks in Advance

解决方案

Just use the "Name" field of the "method" variable above.

string theName = method.Name;
Console.WriteLine("The method's name is " + theName);

Regards

Adrian


这篇关于codedui中的方法名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆