It's all about the answers!

Ask a question

Unit testing for a .NET app using Jazz Build Engine/RTC


Srinath TV (36105) | asked Jan 12 '10, 9:27 a.m.
Hello,

I have been building a .NET application in C# and so far, have implemented https://jazz.net/wiki/bin/view/Main/SCM15MinutesDemo with email notification.
I was trying to get Unit test thing working, but noticed on internet and everywhere that Ant supports JUnit, hence stuck again :(
Is there a way to use ANT Tasks for UNIT Testing ??? Please help..

Somethings which I tried was, executing UnitTests.dll using MSTest.exe ( using
"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe" /testcontainer:E:\build\Source\MyProject.UnitTests\bin\Release\MyProject.UnitTests.dll /resultsfile:E:\buildscript\results.xml ).It did not help me much, still trying .. (was I on right track, or need something else to do???) EVENTUALLY, I want a HTML test report.

I am also not able to build solution in Release mode, and Release folder is not getting created along with debug folder in the bin of project. Is ( "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" MyProject.sln /Rebuild Release ) , the way to build solution in release mode (when the command is used the batch file)?

I am not sure, how to get UNIT Test thing implemented for C# application here.. Please guide, EVENTUALLY, I want a HTML test report created.Is there a way to use ANT Tasks for the same? or something else? Please guide/suggest/help, if possible, with CODE SNIPPETS etc? Thank you..

Regards,
Geny

One answer



permanent link
Krishna Kishore (50112) | answered Jan 22 '10, 3:52 a.m.
JAZZ DEVELOPER
Hi,

The command you are using to build the solution is correct but to build the solution in a given configuration, that configuration should be defined in the solution. Check the Build configurations of the projects in Visual Studio and make sure that the "Release" configuration is defined for the projects/solution and the output directory for the Release configuration is set correctly.

If you are using RTC Version 2.0.0.2 you can use the ANT tasks to upload the MSTest result to a build result. The test results file will be parsed and the individual test results will be displayed under the "Junits" tab of the build result page.

To achive this you need to add the following definition/target to the jazzbuild.xml file:

<target>
__ fail message="Missing repositoryAddress" unless="repositoryAddress"/>
__ fail message="Missing buildResultUUID" unless="buildResultUUID"/>
__ fail message="Missing userId" unless="userId"/>
__ fail message="Missing password" unless="password"/>
__ fail message="Missing file path" unless="filePath"/>
__ fail message="Missing Component Name" unless="componentName"/>

<mstestLogPublisher buildResultUUID="${buildResultUUID}"
repositoryAddress="${repositoryAddress}"
userId="${userId}"
password=${passwordFile}"
filePath="${filePath}"
verbose="true"
componentName="${componentName}"/>
</target>


Note: replace "__" with "<", i put this to avoid xml formatting.

Example call to this ANT task from a BAT file would be



java -cp C:\demoblank\rtc\jazz\buildsystem\buildengine\eclipse\plugins\org.apache.ant_1.7.0.v200803061910\lib\ant-launcher.jar org.apache.tools.ant.launch.Launcher -f "C:\demoblank\buildScript\jazzbuild.xml" -lib C:\demoblank\rtc\jazz\buildsystem\buildtoolkit -DuserId=geny -Dpassword=geny -DrepositoryAddress=h%1 -DbuildResultUUID=%2 -DfilePath="c:\Logs\UnitTests.trx" -DcomponentName="UnitTests.trx" publishMSTestLog


Note that MSTest generates a file with "trx" extension as the test result file, this file will be in XML format not HTML. I dont think MSTest generates a HTML file as output.

If you are using RTC version earlier then 2.0.0.2 then this ANT task of publishing a MSTest results file is not available. In this case you can use the "artifactFilePublisher" ANT task to upload the file to the build result. You need to modify the "jazzbuild.xml" file and parametrize the "artifactFilePublisher" task to take a file path as input, currently the file path is hardcoded in the example "jazzbuild.xml" file.

If you open the build result from VS and click on the uploaded MSTest result file, it will open within VS and you would see the test results in the VS Test view.

Hope this helps.

Thanks,
Kishore

Hello,

I have been building a .NET application in C# and so far, have implemented https://jazz.net/wiki/bin/view/Main/SCM15MinutesDemo with email notification.
I was trying to get Unit test thing working, but noticed on internet and everywhere that Ant supports JUnit, hence stuck again :(
Is there a way to use ANT Tasks for UNIT Testing ??? Please help..

Somethings which I tried was, executing UnitTests.dll using MSTest.exe ( using
"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe" /testcontainer:E:\build\Source\MyProject.UnitTests\bin\Release\MyProject.UnitTests.dll /resultsfile:E:\buildscript\results.xml ).It did not help me much, still trying .. (was I on right track, or need something else to do???) EVENTUALLY, I want a HTML test report.

I am also not able to build solution in Release mode, and Release folder is not getting created along with debug folder in the bin of project. Is ( "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" MyProject.sln /Rebuild Release ) , the way to build solution in release mode (when the command is used the batch file)?

I am not sure, how to get UNIT Test thing implemented for C# application here.. Please guide, EVENTUALLY, I want a HTML test report created.Is there a way to use ANT Tasks for the same? or something else? Please guide/suggest/help, if possible, with CODE SNIPPETS etc? Thank you..

Regards,
Geny

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.