Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 303
user576700 Avatar asked May 27 '14 09:05

user576700


People also ask

How do I run xUnit tests in Teamcity?

Using the pluginDownload and install the plugin as per Teamcity documentation. Select the xUnit runner for the build step, then select the version of xUnit your tests are written in, and finally a pattern to match your test binaries. Wildcards are supported, such as **/*. Tests.

Do xUnit tests run in order?

Each test class is a unique test collection and tests under it will run in sequence, so if you put all of your tests in the same collection then it will run sequentially.

Does xUnit run tests in parallel?

In our case, the strategy is to reassign all test cases to a new collection, and then let xUnit execute the tests. As all tests are in a different collection, xUnit will execute them in parallel. That is that simple!

What test runners can be used to test xUnit.net tests?

Running tests with Visual Studiorunner. visualstudio ). If you have Visual Studio Community (or a paid-for version of Visual Studio), you can run your xUnit.net tests within Visual Studio's built-in test runner (named Test Explorer).


1 Answers

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

like image 190
user576700 Avatar answered Oct 13 '22 11:10

user576700