Teamcity output has a guid behind the testname
Closed this issue · 5 comments
After update from version 2.4.5 to 2.5.3 the testname in teamcity has a guid at the end.
it looks like this guid is for the class, as different tests (in the same class) always have the same guid.
unfortunately i can't find a solution for this because i can't find a suitable change to the code.
I hope that I can find a solution here.
Thanks.
The only change to TeamCity handling was a fix for this issue: xunit/xunit#2385
This was entirely related to flow IDs (which, yes, are GUIDs). If TeamCity is surfacing these GUID flow IDs, then I'm not sure there's anything we can do about that. They're intended to be opaque unique identifiers.
This is the commit where those changes took place: xunit/xunit@cd43469
The handling of test names has not changed here.
the problem we have is that the id (presumably the collection-id) is used to assign the tests in teamcity.
previously it was always "1", now with the latest versions (> 2.5.0) it is a guid.
this means that the entire test history has disappeared because the tests can no longer be assigned to the old recordings using this id.
is there a way to manipulate this id? and if so, how?
I am aware that it is not correct, but here big problem x.x
There is no way to manipulate this ID. Unfortunately the only way you can keep the old behavior is to stick with xunit.runner.visualstudio
2.4.5. Fixing the linked bug to correctly generate flow IDs means breaking any dependencies on the old, broken flow IDs.
var type = output.GetType();
var testMember = type.GetField("test", BindingFlags.Instance | BindingFlags.NonPublic);
var test = (ITest)testMember.GetValue(output);
var testClass = (TestClass)((TestMethod)((TestMethodTestCase)((XunitTest)test).TestCase).TestMethod).TestClass;
var sHA256 = SHA256.Create();
byte[] byte32hash = sHA256.ComputeHash(Encoding.UTF8.GetBytes($"{testClass.Class.Name}.{test.DisplayName}"));
string guid = BitConverter.ToString(byte32hash.Take(16).ToArray()).Replace("-", "").ToLower();
var testCollection = (TestCollection)testClass.TestCollection;
testCollection.UniqueID = Guid.Parse(guid);
This is a possibility to change the TestCollectionId repeatedly.
But now TeamCity has the problem that this Id does not always arrive, probably due to the runner.
After tons of testing, logs and so on,
i think, the problem is, that i change the id too late.
see below into a teamcitylog:
##teamcity[flowStarted timestamp='2023-11-22T14:10:35.674+0000' flowId='Tests.dll']
##teamcity[testSuiteStarted timestamp='2023-11-22T14:10:35.674+0000' flowId='Tests.dll' name='Tests.dll']
##teamcity[flowStarted timestamp='2023-11-22T14:10:35.696+0000' flowId='2add22413a6b4d3f8e5bae96850a15d2' parent='Tests.dll']
##teamcity[testSuiteStarted timestamp='2023-11-22T14:10:35.696+0000' flowId='2add22413a6b4d3f8e5bae96850a15d2' name='Test collection for NamespaceDummyName.ClassDummyName (2add22413a6b4d3f8e5bae96850a15d2)']
##teamcity[testStarted timestamp='2023-11-22T14:10:35.721+0000' flowId='2add22413a6b4d3f8e5bae96850a15d2' name='TestDummyName']
##teamcity[testStdOut timestamp='2023-11-22T14:10:35.950+0000' flowId='25ef915924ff7813476ec6043bb3cee5' name='TestDummyName' out='Loading config: Done.|r|nStarting test.|r|n' tc:tags='tc:parseServiceMessagesInside']]
##teamcity[testFinished timestamp='2023-11-22T14:10:35.950+0000' flowId='25ef915924ff7813476ec6043bb3cee5' name='TestDummyName' duration='220']
##teamcity[testSuiteFinished timestamp='2023-11-22T14:10:35.952+0000' flowId='25ef915924ff7813476ec6043bb3cee5' name='Test collection for NamespaceDummyName.ClassDummyName (25ef915924ff7813476ec6043bb3cee5)']
##teamcity[flowFinished timestamp='2023-11-22T14:10:35.953+0000' flowId='25ef915924ff7813476ec6043bb3cee5']
##teamcity[testSuiteFinished timestamp='2023-11-22T14:10:35.953+0000' flowId='Tests.dll' name='Tests.dll']
##teamcity[flowFinished timestamp='2023-11-22T14:10:35.953+0000' flowId='Tests.dll']
The 2nd guid is created with the code from top in the constructor of the base-testing-class.
the 1st guid cames from the xunit.console.runner.exe, but every time you start the runner again, it is different.