未为TestRunState.Completed引发TestRunChangedNotification [英] TestRunChangedNotification not raised for TestRunState.Completed

查看:72
本文介绍了未为TestRunState.Completed引发TestRunChangedNotification的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为一些测试管理事件编写了服务器端处理程序,并且发现了越来越多的问题.首先,我可以侦听要跟随的Microsoft.TeamFoundation.TestManagement.Server.TestRunChangedNotification事件 更改为排队的测试运行,但看来完成"状态实际上并未引发该事件.可以说,一个要跟踪的两个最重要的状态是运行开始和运行完成,但是完成似乎并没有引发该事件!是 有没有办法解决这个问题?!

I have written a server-side handler for several of the the test management events, and I'm finding more and more issues. First and foremost, I can listen for the Microsoft.TeamFoundation.TestManagement.Server.TestRunChangedNotification event to follow changes to a queued test run, but it appears that the Completed state does not actually raise the event. Arguably the two most important states that one would track are run started and run completed, but Completed does not even seem to raise the event! Is there any way to figure this out?!

更笼统地说,我发现大多数与测试管理相关的事件的设计都是无用的:可以引发许多不同的事件,但是关于_what_actually_occurred_引发事件的内容很少或没有任何上下文.这 第一名.例如:

More generally, I'm finding the design of most of the test management related events fairly useless: there are a number of different events which can be raised, but little to no context is included as to _what_actually_occurred_ to raise the event in the first place. For example:

(大概)引发了TestSuiteChangedNotification事件,以指示测试套件中的更改,但是事件args仅包含项目&的ID.套件发生了变化,而不是实际发生的变化.有了这些信息,就不得不去找 套件并手动识别实际更改-除非您的应用程序不断跟踪测试套件本身(实际上必须对TFS应该已经跟踪的所有内容执行双重分类帐),否则这几乎是不可能的.甚至知道 只有测试套件的哪些属性发生更改才能导致事件发生,才比当前实现更好.这就像被告知:1)乔发生了什么事. 2)我不会告诉你Joe发生了什么,以及3)你不能问Joe发生了什么. 完全没用.

The TestSuiteChangedNotification event is (presumably) raised to indicate a change in a test suite, but the event args only contains the id of the project & suite which changed, NOT what actually did change. With this information one has to go retrieve the suite and discern manually what actually changed -- which seems near impossible unless your application is constantly keeping track of test suites itself (effectively having to do dual-ledger for everything TFS should already be tracking). Even knowing only what properties of the test suite changed to cause the event would be better than the current implementation. This is like being told: 1) Something happened to Joe. 2) I'm not going to tell you WHAT happened to Joe, and 3) You can't ask Joe what happened. Pretty useless.

推荐答案

后续说明:处理TestRunChangedNotification事件的示例代码片段(当前未引发):

Followup note: a snippet of sample code handling the TestRunChangedNotification event (and not being raised currently):

如果(notificationType == NotificationType.Notification
    && requestContext.ServiceHost是CollectionServiceHost)
{
  ...
  if(notificationEventArgs是Microsoft.TeamFoundation.TestManagement.Server.TestRunChangedNotification)
  {
    Microsoft.TeamFoundation.TestManagement.Server.TestRunChangedNotification runChangeEvent =
        notificationEventArgs作为Microsoft.TeamFoundation.TestManagement.Server.TestRunChangedNotification;
    TeamFoundationTrace.Info(项目{0}运行{1}已更改.",runChangeEvent.ProjectName,runChangeEvent.TestRunId);

if (notificationType == NotificationType.Notification
    && requestContext.ServiceHost is CollectionServiceHost)
{
 ...
 if (notificationEventArgs is Microsoft.TeamFoundation.TestManagement.Server.TestRunChangedNotification)
 {
     Microsoft.TeamFoundation.TestManagement.Server.TestRunChangedNotification runChangeEvent =
         notificationEventArgs as Microsoft.TeamFoundation.TestManagement.Server.TestRunChangedNotification;
     TeamFoundationTrace.Info("Project {0} Run {1} changed.", runChangeEvent.ProjectName, runChangeEvent.TestRunId);

    ITestManagementService tms = coll.GetService< ITestManagementService>();
    IEnumerable< ITestRun>运行= tms.QueryTestRuns(
        string.Format("SELECT * FROM TestRun WHERE TestRunId = {0}",runChangeEvent.TestRunId));
    foreach(ITestRun在运行中运行)
    {
        TeamFoundationTrace.Info("Run:{0} [{1}]",run.Title,run.State);
    }
 }
...
}

     ITestManagementService tms = coll.GetService<ITestManagementService>();
     IEnumerable<ITestRun> runs = tms.QueryTestRuns(
         string.Format("SELECT * FROM TestRun WHERE TestRunId={0}", runChangeEvent.TestRunId));
     foreach (ITestRun run in runs)
     {
         TeamFoundationTrace.Info("Run: {0} [{1}]", run.Title, run.State);
     }
 }
...
}


这篇关于未为TestRunState.Completed引发TestRunChangedNotification的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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