nunit / teamcity-event-listener

NUnit Engine extension that helps integration with teamcity
MIT License
11 stars 10 forks source link

Colon's in testcase data are replaced with <space> in the Teamcity service messages #68

Closed chrisgeorge0911 closed 5 years ago

chrisgeorge0911 commented 5 years ago

Nunit 3.11 / Nunit console 3.10

Having a simple parameterised testcase such as

[TestCase("test1", ":")]
[TestCase("test2", "-")]
public void TestMethod1(string name, string data)
{
    Assert.IsTrue(true);
}

Runs fine, but with --teamcity, the resulting teamcity service messages look like:

##teamcity[flowStarted flowId='PID_31160_0-1004' parent='PID_31160']
##teamcity[testSuiteStarted name='UnitTestProject1.dll' flowId='PID_31160_0-1004']
##teamcity[flowStarted flowId='PID_31160_0-1001' parent='PID_31160_0-1004']
##teamcity[testStarted name='UnitTestProject1.UnitTest1.TestMethod1("test1"," ")' captureStandardOutput='false' flowId='PID_31160_0-1001']
##teamcity[testFinished name='UnitTestProject1.UnitTest1.TestMethod1("test1"," ")' duration='13' flowId='PID_31160_0-1001']
##teamcity[flowFinished flowId='PID_31160_0-1001']
##teamcity[flowStarted flowId='PID_31160_0-1002' parent='PID_31160_0-1004']
##teamcity[testStarted name='UnitTestProject1.UnitTest1.TestMethod1("test2","-")' captureStandardOutput='false' flowId='PID_31160_0-1002']
##teamcity[testFinished name='UnitTestProject1.UnitTest1.TestMethod1("test2","-")' duration='0' flowId='PID_31160_0-1002']
##teamcity[flowFinished flowId='PID_31160_0-1002']
##teamcity[testSuiteFinished name='UnitTestProject1.dll' flowId='PID_31160_0-1004']
##teamcity[flowFinished flowId='PID_31160_0-1004']

Notice the lack of colon's in the test1 lines.

This becomes a problem when there are other parameterised tests that actually pass a space, because teamcity underreports the number of issues as they are not unique.

CharliePoole commented 5 years ago

This is likely to be a bug in the teamcity extension but to be sure, can you tell us what the name of the test case is in the XML result?

ChrisMaddock commented 5 years ago

Below is an output from the latest console/teamcity extension which outputs both the NUnit Console's labels, and the TeamCity messages. From this, the problem appears to lie in the teamcity extension - I'll transfer this issue over shortly. 🙂

C:\Users\chris\OneDrive\Documents\git\NUnitTest>nunit3-console "bin/Debug/net45/NUnitTest.dll" --teamcity --labels=Before
NUnit Console Runner 3.10.0 (.NET 2.0)
Copyright (c) 2019 Charlie Poole, Rob Prouse
30 May 2019 23:26:25

Runtime Environment
   OS Version: Microsoft Windows NT 10.0.17134.0
  CLR Version: 4.0.30319.42000

Test Files
    bin/Debug/net45/NUnitTest.dll

##teamcity[flowStarted flowId='PID_4552_0-1004' parent='PID_4552']
##teamcity[testSuiteStarted name='NUnitTest.dll' flowId='PID_4552_0-1004']
=> Tests.Tests.TestMethod1("test1",":")
##teamcity[flowStarted flowId='PID_4552_0-1001' parent='PID_4552_0-1004']
##teamcity[testStarted name='Tests.Tests.TestMethod1("test1"," ")' captureStandardOutput='false' flowId='PID_4552_0-1001']
##teamcity[testFinished name='Tests.Tests.TestMethod1("test1"," ")' duration='11' flowId='PID_4552_0-1001']
NikolayPianikov commented 5 years ago

@chrisgeorge0911 unfortunately I have to replace the colon symbol because of TeamCity treats it as a delimiter of an assembly name and a test class/method name. As alternative I could replace it by '%3A' for instance. But in your test report you will see the line like Tests.Test1("test1","%3A"). Or I could add a parameter to specify a replacement string.

chrisgeorge0911 commented 5 years ago

@chrisgeorge0911 unfortunately I have to replace the colon symbol because of TeamCity treats it as a delimiter of an assembly name and a test class/method name. As alternative I could replace it by '%3A' for instance. But in your test report you will see the line like Tests.Test1("test1","%3A"). Or I could add a parameter to specify a replacement string.

@NikolayPianikov how about replacing ":" with "\<colon>"? My worry with "%3A" is that its more likely to be used as a parameter along with specifying the actual ":" character. "\<colon>" is very unlikely to be used as a parameter, but would still uniquely identify that particular test case.

NikolayPianikov commented 5 years ago

@chrisgeorge0911 Ok, I will add the environment variable to specify the value for this replacement and by default it will be "". Thank you

chrisgeorge0911 commented 5 years ago

Sounds great 👍 thanks

NikolayPianikov commented 5 years ago

Fix will be available in NUnit.Extension.TeamCityEventListener 1.0.7

abelbraaksma commented 4 years ago

For reference, as this isn't currently anywhere on the net, the environment variable you can use to override the default <colon> is TEAMCITY_COLON_REPLACEMENT.