Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
chrisgeorge0911 opened this issue May 24, 2019 · 8 comments
Assignees
Labels

Comments

@chrisgeorge0911
Copy link

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
Copy link
Member

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
Copy link
Member

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']

@ChrisMaddock ChrisMaddock transferred this issue from nunit/nunit-console May 30, 2019
@NikolayPianikov NikolayPianikov self-assigned this May 31, 2019
@NikolayPianikov
Copy link
Member

@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
Copy link
Author

chrisgeorge0911 commented Jun 3, 2019

@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
Copy link
Member

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

@chrisgeorge0911
Copy link
Author

Sounds great 👍 thanks

NikolayPianikov pushed a commit that referenced this issue Jun 13, 2019
@NikolayPianikov
Copy link
Member

Fix will be available in NUnit.Extension.TeamCityEventListener 1.0.7

@abelbraaksma
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants