First you need to convert MSTest results in to XML and then to HTML using xstl to publish it as an HTML report in Jenkins.
Step 1
GO to your test local.settings file in visual studio and set it to display the code coverage results an add your required targeted dll's. This is same as configuring visual studio to show the test results and code coverage.
Make sure you have added the test settings file to your version controlling system then it will be in the working space of the jenkins.
Then set path to the MSTest.exe
it may be in your
Step 2
Add a windows batch command to run MSTest (after running ms build) and to generate test results file (“reults.trx”) and Coverage report (“data.coverage”)
del results.trx
mstest /testcontainer:Example\TestProject1\bin\debug\TestProject1.dll /resultsfile:results.trx /testsettings:Example\local.testsettings
This will generate a code coverage result in binary format (data.coverage)
Step 3
write a console app to convert binary data.coverage file in to a XML and then it to HTML by xslt and run it after adding windows batch command in jenkins. Here is the example code for console app. Make sure you have add reference to Microsoft.VisualStudio.Coverage.Analysis.dll which you can find in the
And here is the code of the style.xslt file
Hello!
ReplyDeleteCould you please share javascript file script1.js. I cannot use generated report without it.
Add JQuery Reference in 1st Line of head tag and then put this Javascript function below inside script tag
Deletefunction toggleDetail(control)
{
var ctrlId = $(control).attr('Id');
$("tr[id='"+ctrlId +"']").toggle();
}
It works for me now. Thank you very much.
DeleteAh... First of all I didn't see your fist comment about script1.js and thank @Arpit , I think your way is better rather than using plain JavaScript. Thanks all for helping me for to have a valuable article. Will update it...
DeleteThanks Jayantha for your great effort.
DeleteWe have also changed its styling...
As it is not allowing to paste html code I have pasted it at
http://codesharpe.blogspot.in/
Jayantha, I have a simple query as can we also link source file on function click and show which line is executed as it is possible in ncover with same xml. And can we have one more column for total lines of code.
Thanks
Arpit Nagar
i getting the html report but when i am expanding the nodes using + nothing is happening for me. I am expecting it will open the child nodes..please clarify
ReplyDeletePlease refer the previous comment thread. There was some issues with js files. .
Delete"Add JQuery Reference in 1st Line of head tag and then put this Javascript function below inside script tag
function toggleDetail(control)
{
var ctrlId = $(control).attr('Id');
$("tr[id='"+ctrlId +"']").toggle();
}"
Thanks Jayantha..i made the changes...i am still facing the issue...
ReplyDeletemy html script tag is like this
script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"
but when i change this to below manually..it is working
script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"
/script
but how to get rid of this programatically..I removed < tags in text in order to post..it is not accepting script tags
i managed to get it work Jayantha...thanks you very much..it was very helpful
ReplyDeleteIt's very helpful! Can I translate this post into Japanese on my blog? Or Do you know some site which has already done?
ReplyDelete@Kazunari Tanaka, yes you can do it .
DeleteThanks a lot! please wait until it's done.
Deletedone it. little bit change your original code. Anyway thank you for your generous.
Deletehttp://axtstar.com/blog/?page_id=258