unit-testingcontinuous-integrationteamcityxunit.netteamcity-7.0

How does TeamCity know when an xUnit.net test is run?


I have always wondered how TeamCity recognizes that it is running xUnit.net tests and how it knows to put a separate "Test" tab in the build overview after a build step runs. Is the xUnit console runner somehow responsible for that?


Solution

  • Found finally what is actually going on. TeamCity has its own API. I dug this code snippet out of the xUnit source code and it becomes clear:

    https://github.com/xunit/xunit/blob/v1/src/xunit.console/RunnerCallbacks/TeamCityRunnerCallback.cs

     public override void AssemblyStart(TestAssembly testAssembly)
        {
            Console.WriteLine(
                "##teamcity[testSuiteStarted name='{0}']",
                Escape(Path.GetFileName(testAssembly.AssemblyFilename))
            );
        }
    

    ...code omitted for clarity