Reputation: 23462
I'm making a request to guestAuth/app/rest/builds/id:2777/statistics
as defined here, http://confluence.jetbrains.com/display/TW/REST+API+Plugin#RESTAPIPlugin-OtherBuildRequests. If I understand the documentation correctly it is supposed to list the parameters defined here, http://confluence.jetbrains.com/display/TCD8/Custom+Chart#CustomChart-listOfDefaultStatisticValues, but I can't find the PassedTestCount
and FailedTestCount
.
Is there another way to get those values?
Upvotes: 2
Views: 2792
Reputation: 5468
If I understand correctly, the way TeamCity works is if the Tests that are run are supported they will show up under the Tests
tab for a build, then you will be able to see those in two places in the REST API.
First under /guestAuth/app/rest/builds/id:X
where X is the Build ID Number. What you will see is a <statusText>
tag which will contain text like:
<statusText>Tests passed: 4</statusText>
<statusText>Tests failed: 2 (2 new), passed: 6</statusText>
<statusText>Tests failed: 2, passed: 6</statusText>
That you could in theory parse out to get your numbers.
However, they are also under /guestAuth/app/rest/builds/id:X/statistics
using the following tags:
<property name="FailedTestCount" value="2"/>
<property name="PassedTestCount" value="6"/>
However, should there be no failed tests, the "FailedTestCount" property tag won't be there.
If your tests are not showing up under the Test
, then you can look into TeamCity Service Messages for Build Script Interaction that can Report Test Start / End with Failure in the middle if found.
For example, you can create a new build with just a Command Line Custom Script build step with:
echo "##teamcity[testSuiteStarted name='suite.name']"
echo "##teamcity[testSuiteStarted name='nested.suite']"
echo "##teamcity[testStarted name='package_or_namespace.ClassName.TestName']"
echo "##teamcity[testFailed name='package_or_namespace.ClassName.TestName' message='The number should 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[testStarted name='package_or_namespace.ClassName.TestNameTwo']"
echo "##teamcity[testFinished name='package_or_namespace.ClassName.TestNameTwo']"
echo "##teamcity[testSuiteFinished name='nested.suite']"
echo "##teamcity[testSuiteFinished name='suite.name']"
And it will end up showing:
<property name="FailedTestCount" value="1"/>
<property name="PassedTestCount" value="1"/>
Under /guestAuth/app/rest/builds/id:X/statistics
if you run the test. Hope that helps.
Upvotes: 3