tcWebHooks: Muted test webhook doesn't include test name

I’m checking out the new test muted and test unmuted events, to see how we can tie this into our other systems.

For unmuted, we get the test name, but for muted, we dont get the test name.

Expected Behavior

buildEventType | TESTS_UNMUTED
mutedOrUnmutedTests | {4=[suiteName: nestedSuiteName: package_or_namespace.ClassName.TestName]}
buildEventType | TESTS_MUTED
mutedOrUnmutedTests | {4=[suiteName: nestedSuiteName: package_or_namespace.ClassName.TestName]}

(I’m not 100% sure what the 4 is about…)

Current Behavior

buildEventType | TESTS_UNMUTED
mutedOrUnmutedTests | {4=[suiteName: nestedSuiteName: package_or_namespace.ClassName.TestName]}
buildEventType | TESTS_MUTED
mutedOrUnmutedTests | {5=[]}

Steps to Reproduce (for bugs)

Create a basic teamcity project, add a command line runner with the following content:

echo "##teamcity[testSuiteStarted name='suiteName']"
echo "##teamcity[testSuiteStarted name='nestedSuiteName']"
echo "##teamcity[testStarted name='package_or_namespace.ClassName.TestName']"
echo "##teamcity[testFailed name='package_or_namespace.ClassName.TestName' message='The number must be 20000' details='junit.framework.AssertionFailedError: expected:<20000> but was:<10000>|n|r    at junit.framework.Assert.fail(Assert.java:47)|n|r    at junit.framework.Assert.failNotEquals(Assert.java:280)|n|r...']"
echo "##teamcity[testFinished name='package_or_namespace.ClassName.TestName']"
echo "##teamcity[testSuiteFinished name='nestedSuiteName']"
echo "##teamcity[testSuiteFinished name='suiteName']"

Add a webhook that triggers on mute and unmute. Mute / unmute the test.

Your Environment

  • tcWebHooks Version: 1.2.2
  • TeamCity Version: 2023.05
  • TeamCity server Operating System: Linux
  • Are you using a WebHook Template?: Legacy Webhook (Name Value Pairs)

Investigation so far

Looking at the code, in WebhookListener.java, it creates a new map, but we could potentially change it from

this.processTestEvent(BuildStateEnum.TESTS_MUTED, null, Collections.singletonMap(muteInfo, new ArrayList<>()));

to

this.processTestEvent(BuildStateEnum.TESTS_MUTED, null, Collections.singletonMap(muteInfo, muteInfo.getTests()));

and I think it should work… (Note that I haven’t tested this at all)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

I’ve updated the instructions at https://github.com/tcplugins/tcWebHooksTemplates

I am looking at exactly that file right now 😃

~Another question with this… What is the 13= and 11= on these?~

~I’m using the legacy / deprecated name value pairs format to get these, so it may just be a side affect of that, but not entirely sure how they’ll format in json?~

Nevermind: figured it out… It’s the default .toString() implementation of MuteInfo - it just renders the id.

Hmm. ~~Looking at the code in that file on line 121, I don’t think it ever worked for muted.

It checks for a non-empty list of tests before executing the webhook. School boy error. 🫣~~

Ignore. It’s too late. I’m not being sense.