VSTS - 测试记录文件为空

VSTS - Test Recording files empty

对于我们当中的 VSTS(或 TFS)专家...

我遇到一个问题,即 Microsoft Expression Encoder SDK 生成的录制文件显示为空。上下文的小描述:

我们正在 VSTS 环境中工作,并设置了构建定义和多个发布定义。此流程正常运行。完成签入、构建触发器和完成、发布开始和完成,直到 UI 测试 运行 的最后一个版本并以正确的结果结束。我们正在使用一个构建代理和一个单独的测试代理(都是 Windows 10 OS),它们在同一个域中并且可以毫无问题地相互连接。

我正在尝试在测试场景中包含录音。我在我的膝上型电脑(也用作构建代理)和测试代理上安装了 Microsoft Expression Encoder SP 2。在这两个系统上,我都可以毫无问题地手动进行录音。在本地(来自 Visual Studio 本身)进行测试 运行 时,会相应地创建一个记录。

现在的问题是:当测试代理开始测试时 运行s,记录文件被创建,但它们最终都是 4.93kb 的文件,没有任何内容。我可以打开它们,但它们有 0:00 运行 时间。构建日志或事件查看器中未显示任何错误:我得到的只是空文件。

一些相关背景代码:

    [SetUp]
    public void Initialize()
    {
        testName = TestContext.CurrentContext.Test.Name;

        var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\Recordings";
        Directory.CreateDirectory(path);
        recorder = new ScreenCaptureJob
        {
            OutputScreenCaptureFileName = path + @"\" + testName + @".xesc",
            CaptureRectangle = new Rectangle(0, 0, 1024, 768),
            ShowFlashingBoundary = false,
            CaptureMouseCursor = false,
            CaptureFollowCursor = false,
            CaptureLargeMouseCursor = false,
            CaptureLayeredWindow = false,
            ShowCountdown = false
        };

        Logger.Logger.Log(recorder.OutputScreenCaptureFileName); 

        if (File.Exists(recorder.OutputScreenCaptureFileName))
        {
            File.Delete(recorder.OutputScreenCaptureFileName);
        }

        recorder.Start();

        /* Navigation to baseUrl */
        Driver.Navigate().GoToUrl(startUrl);
        WaitForUrl(startUrl);
        recorder.Stop();
    }

有没有人知道是什么(缺乏)魔法导致了这个问题?如果分析需要更多信息,我很乐意提供。

提前致谢!

-编辑- 回应 Wouter:我应该注意到构建代理使用测试代理的管理员帐户登录,所以权限应该(可能?)不是问题。

-编辑 2- 我在整个过程中添加了一些日志记录,这显示了一些有趣的东西:

2017-12-14 10:51:29.322 C:\TestDrop*censored*\drop\bin\Debug\Recordings_LoadHomePage_ClickMenuQuestions_NavigatedToJobs.xesc

2017-12-14 10:51:29.322 posX  : 0
2017-12-14 10:51:29.337 posY  : 0
2017-12-14 10:51:29.337 width : 1024
2017-12-14 10:51:29.337 height: 768
2017-12-14 10:51:29.353 Size before starting: 0
2017-12-14 10:51:29.353 Status before starting: NotStarted
2017-12-14 10:51:29.353 Duration before starting: 00:00:00
2017-12-14 10:51:29.369 Framecount before starting: 0
2017-12-14 10:51:29.400 Size started        : 0
2017-12-14 10:51:29.415 Status started        : Running
2017-12-14 10:51:29.415 Duration started        : 00:00:00.0111608
2017-12-14 10:51:29.415 Framecount started        : 1
2017-12-14 10:51:44.315 Size close to ending: 0
2017-12-14 10:51:44.320 Status close to ending: Running
2017-12-14 10:51:44.324 Duration close to ending: 00:00:14.9117567
2017-12-14 10:51:44.332 Framecount close to ending: 190
2017-12-14 10:51:44.344 Size stopped        : 0
2017-12-14 10:51:44.349 Status stopped        : NotStarted
2017-12-14 10:51:44.354 Duration stopped        : 00:00:00
2017-12-14 10:51:44.359 Framecount stopped        : 0

看来,录音实际上是运行ning。在 recorder.stop() 之前,帧数为 190,但文件大小保持为 0。当 运行 在本地测试时,我得到以下信息:

2017-12-14 10:48:31.861 posX  : 0
2017-12-14 10:48:31.867 posY  : 0
2017-12-14 10:48:31.872 width : 1024
2017-12-14 10:48:31.877 height: 768
2017-12-14 10:48:31.882 Size before starting: 0
2017-12-14 10:48:31.888 Status before starting: NotStarted
2017-12-14 10:48:31.893 Duration before starting: 00:00:00
2017-12-14 10:48:31.898 Framecount before starting: 0
2017-12-14 10:48:31.948 Size started        : 0
2017-12-14 10:48:31.952 Status started        : Running
2017-12-14 10:48:31.956 Duration started        : 00:00:00.0090997
2017-12-14 10:48:31.963 Framecount started        : 0
2017-12-14 10:48:53.630 Size close to ending: 9998272
2017-12-14 10:48:53.634 Status close to ending: Running
2017-12-14 10:48:53.640 Duration close to ending: 00:00:21.6936283
2017-12-14 10:48:53.647 Framecount close to ending: 322
2017-12-14 10:48:53.669 Size stopped        : 0
2017-12-14 10:48:53.675 Status stopped        : NotStarted
2017-12-14 10:48:53.681 Duration stopped        : 00:00:00
2017-12-14 10:48:53.685 Framecount stopped        : 0

这里唯一的区别是文件大小,即结束前的 9998272。我认为这确实表明存在权限问题,尽管我仍然对为什么可以创建视频而不是编写视频感到困惑...

已找到解决方法。由于 Expression Encoder 本身在 Test-Agent 上运行良好,我编写了一个 运行s 在 Test-Agent 本身上的小应用程序,它正在侦听来自网络上其他设备的调用。当收到像 "start" 或 "stop" 这样的简单命令时,应用程序会在本地(因此,在 Test-Agent 上)使用 Expression Encoder SDK 来启动或停止录制。由于应用程序在本地 运行,因此可以防止任何可能的权限问题。最终,我们会将应用程序转换为 windows 服务,以简化使用。

虽然这在技术上不是问题的答案,但至少我们有一些可以解决的问题。感谢大家的回复!

编辑: 在使用上述解决方案时,我们发现了实际问题所在:记录过程未在 交互式会话 中找到位置。 运行宁作为一项 windows 服务,因此没有实际的屏幕可以录制。

显然 VSTS 对此有一个简单的解决方案。任务 "Visual Studio Test Agent Deployment" 实际上有一个复选框,字面意思是 "Run UI tests"。由于某种原因我之前错过了它,我认为它在TFS2015中被称为"Run as interactive session"

选中此按钮,(在我的情况下)Expression Encoder 保存录音没有问题。