当前上下文中不存在名称“AutomationId”

时间:2015-04-01 11:31:06

标签: c# testing ui-testing white

我使用UI自动化测试进行组装(白色)。

我已经介绍了一个包含所有自动识别ID的课程,可以在这个程序集中重复使用:

public static class AutomationId
{
    public static class Toolbar
    {
        public const string MyControl = "MyControlId";
    }
}

现在我试图在我的测试类(同一个程序集)中使用它:

var control = mainWindow.Get<Button>(AutomationId.Toolbar.MyControl);

此代码可以在本地编译。但是在TeamCity上我遇到了这样的错误:

The name 'AutomationId' does not exist in the current context

1 个答案:

答案 0 :(得分:2)

它是C#6的功能。类似的问题:The name 'nameof' does not exist in the current context

我刚刚遇到这个问题,这引导我到这里来。我的研究表明您需要更新Teamcity:

http://dave.ninja/2015/08/06/upgrading-teamcity-to-support-visual-studio-2015/

我们仍然必须这样做。上面的帖子显示了他们在升级时遇到的问题的许多解决方案。不是一个太痛苦的过程。