Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
537 views
in Technique[技术] by (71.8m points)

unit testing - Integrating Hudson with MS Test?

Is it possible to integrate Hudson with MS Test?

I am setting up a smaller CI server on my development machine with Hudson right now, just so that I can have some statistics (ie. FxCop and compiler warnings). Of course, it would also be nice if it could just run my unit tests and present their output.

Up to now, I have added the following batch task to Hudson, which makes it run the tests properly.

"%PROGRAMFILES%Microsoft Visual Studio 9.0Common7IDEMSTest.exe" /runconfig:LocalTestRun.testrunconfig /testcontainer:TestsinDebugTests.dll

However, as far as I know, Hudson does not support analysis of MS Test results, yet. Does anyone know whether the TRX files generated by MSTest.exe can be transformed to the JUnit or NUnit result format (because those are supported by Hudson), or whether there is any other way to integrate MS Test unit tests with Hudson?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've been meaning to write this as a guide and develop a plugin but I havent gotten around to it. I know this question is old but I'm SURE someone else out there wants the same thing so here it is.

In the project configuration on Hudson:

Execute Windows batch command


SET MSTest="C:Program FilesMicrosoft Visual Studio 9.0Common7IDEMSTest.exe"
SET XSLParser="C:MsBuildNunitmsxsl.exe"

SET TestDLL=path-to-your-test-projects.dll
SET TestOutFILE=TestResultssome-unique-filename.trx
SET TransformedOutputFile=%TestOutFILE:.trx=%.xml
SET XSLFile=c:MsBuildNunitMSBuild-to-NUnit.xslt

MKDIR TestResults

%MSTest% "/testcontainer:%TestDLL%" /nologo /resultsfile:%TestOutFILE% 

%XSLParser% %TestOutFILE% %XSLFile% -o %TransformedOutputFile%

SET ERRORLEVEL=0

Then check the box "Publish NUnit test result report" and for "Test report XMLs" enter

TestResults/*.xml

There is an XSLT in C:MsBuildNunit as well as msxsl.exe which comes from Microsoft.

You can download the MSBuild-to-NUnit.xslt from here and get msxsl.exe from microsoft here or you can just get the zipped copy of my MsBuildNunit folder that contains the xslt and exe here

When run, it calls MSTest.exe which runs the tests and outputs the format in microsofts trx (xml) format. Then it calls msxsl.exe with the xslt and the trx and translates it to nunits xml format. At the end of the build, Hudson picks it up as any other Nunit test result and you are good to go.

Edited to add: I forgot to mention, with this xslt we get full test results. We have multiple test projects and multiple dll's and we get great feedback with the ability to trend graph, view the tests by name, view the statuses of the tests, and if it errors we get the error message along with the stack trace. Basically almost everything that you would get with Nunit.

Edit (again): I just now added the test duration in the transform so it will show up in Hudson now! Seems to work great for our tests.

Edit: I tried the new MSTest plugin and it currently does not support parsing multiple TRX files, just 1, so currently this is your only solution if you are like us and have multiple test assemblies that you have to run through MSTest.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...