Forum Discussion
Logging TeamCity readable
results from TestComplete
In TestComplete, while creating script for a test we output
whether test results (passed/failed) to log. Along with this, we could output the
result to a text file which could be recognized by TeamCity. Here is an example
of running a test from TestComplete and logging results that could be read by
TeamCity.
function mainTest(){
UpdateTeamCityResult("##teamcity[testStarted name='LoginTest']");
var stepResult = LoginTest(); //returns passed if test is successful
if (stepResult == "Passed"){
UpdateTeamCityResult("##teamcity[testFinished name='LoginTest']");
}
else{
UpdateTeamCityResult("##teamcity[testFailed name='LoginTest' message='test failed' details='Login test
failed"+ stepResult+"']");
UpdateTeamCityResult("##teamcity[testFinished name='LoginTest']");
}
}
function UpdateTeamCityResult(data){
var
fso = new ActiveXObject("Scripting.FileSystemObject");
var
ForWriting=8;
var TestSetResultFile
= "..\\Reports\\DetailedTestResults\\TeamCityResults.txt";
TestSetResultFile = fso.OpenTextFile(TestSetResultFile,ForWriting,true);
TestSetResultFile.WriteLine(data);
TestSetResultFile.Close();
return true;
}
Printing Teamcity Results
from msbuild
In msbuild script, after running a test, open the
TeamCityResults.txt file and print it to build log, which is then read by
TeamCity automatically. Below is an example where we call the targets for
set of tests and after running test it prints the TeamCity results.
<Target Name="RunTest" Outputs="%(TestFiles.Identity)" >
<Message Text = "%(TestFiles.Identity)"/>
<Exec ContinueOnError="true" Command="$(ProgramFiles) (x86)\Automated QA\TestExecute 8\Bin\TestExecute.exe" $(MSBuildProjectDirectory)\..\..\Tests\TestRunner\TestRunner.pjs /run /project:TestRunner /SilentMode /ns /exit %(TestFiles.Identity)" />
<PropertyGroup>
<TeamCityResultFile>"$(MSBuildProjectDirectory)\..\..\Reports\DetailedTestResults\TeamCityResults.txt"</TeamCityResultFile>
</PropertyGroup>
<Exec ContinueOnError="true" Command="type $(TeamCityResultFile)"/> this line prints the test status
to build log and TeamCity picks this up automatically and updates tests tab
</Target>
Thanks,
Muthu
Related Content
- 4 years ago
- 8 years ago
- 9 years ago
- 14 years ago
Recent Discussions
- 4 days ago
- 4 days ago