Skip to content

Commit 4e4bd7a

Browse files
authored
Additional Logging for TestPlansAndSuitesMigrationContext at FindTestPlan (#1771)
Update to add additional logging and check for null reference when test plan does not match. Usually only happens when test plns have the same name! Updates for #1770
1 parent 2c5de98 commit 4e4bd7a

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

docs/Reference/Generated/MigrationTools.Host.xml

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/VstsSyncMigrator.Core/Execution/MigrationContext/TestPlansAndSuitesMigrationContext.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,18 +624,26 @@ private ITestSuiteBase FindSuiteEntry(IStaticTestSuite staticSuite, string title
624624

625625
private ITestPlan FindTestPlan(TestManagementContext tmc, string name)
626626
{
627+
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan");
627628
ITestPlan testPlan = (from p in tmc.Project.TestPlans.Query("Select * From TestPlan") where p.Name == name select p).SingleOrDefault();
629+
628630
if (testPlan != null)
629631
{
632+
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan:: FOUND Test Plan with {name}", name);
630633
//Check test plan is in fact the right one
631634
var sourceWI = Engine.Source.WorkItems.GetWorkItem(testPlan.Id.ToString());
632635
string expectedReflectedId = Engine.Source.WorkItems.CreateReflectedWorkItemId(sourceWI).ToString();
633636
string workItemReflectedId = (string)sourceWI.Fields[Engine.Target.Config.AsTeamProjectConfig().ReflectedWorkItemIDFieldName].Value;
634637
if (workItemReflectedId != expectedReflectedId)
635638
{
639+
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan:: Fouund test plan with name {name} does not match {workItemReflectedId} ", name, workItemReflectedId);
636640
testPlan = null;
637641
}
638642
}
643+
else
644+
{
645+
Log.LogDebug("TestPlansAndSuitesMigrationContext::FindTestPlan:: NOT FOUND Test Plan with {name}", name);
646+
}
639647
return testPlan;
640648
}
641649

@@ -914,9 +922,17 @@ private void ProcessTestPlan(ITestPlan sourcePlan)
914922
// Load the plan again, because somehow it doesn't let me set configurations on the already loaded plan
915923
InnerLog(sourcePlan, $"ApplyConfigurationsAndAssignTesters {targetPlan.Name}", 5); ;
916924
ITestPlan targetPlan2 = FindTestPlan(_targetTestStore, targetPlan.Name);
917-
ApplyConfigurationsAndAssignTesters(sourcePlan.RootSuite, targetPlan2.RootSuite);
918-
//////////////////////////////
919-
TagCompletedTargetPlan(targetPlan.Id);
925+
if (targetPlan2 != null)
926+
{
927+
ApplyConfigurationsAndAssignTesters(sourcePlan.RootSuite, targetPlan2.RootSuite);
928+
//////////////////////////////
929+
TagCompletedTargetPlan(targetPlan.Id);
930+
}
931+
else
932+
{
933+
Log.LogError("Unable to ApplyConfigurationsAndAssignTesters: When loading the test plan again with the name it was found that they do not match!");
934+
}
935+
920936
///////////////////////////////////////////////
921937
metrics.Add("ElapsedMS", stopwatch.ElapsedMilliseconds);
922938
Telemetry.TrackEvent("MigrateTestPlan", parameters, metrics);

0 commit comments

Comments
 (0)