MSTest task for MSBuild

16 בדצמבר 2007

83 תגובות


I was looking for an ability to run automated tests from MSBuild, my demands are:

1) Be able to run tests from many solutions (that contains many projects and many tests).

2) Be able to control the entire test running definition from one file(and not to open each proj file to add a new test every time someone in my team writes one).

3) Be able to separate sets of tests that take more time to run from those that run with no time – usually it will be divided into unit and integration tests.

4) Do all this without using .vsmdi file – because from some reason this file not work properly within TFS source safe, which me and my team are using.

MSBuild have no task for running units. Those are the alternatives I found for units to run from MSBuild.

1) Run the MSTest command directly,by using exec task, like this

<Exec Command='"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\mstest.exe" /testcontainer:c:\projects\MyTests\Sampe.Tests.dll />

This solution is pretty good if you have one test project to run, if you have more than one you have to specify the "/testcontainer:…" parameter for every project that you want to run. Or add new exec task.

If you have to run it for, let say five solutions, when each one contains more the one test project, you have already ten projects that you have to maintain, and I don’t want to be the one that doing this.

2) Running TestToolsTask task which comes with TFS and can be found in Microsoft.TeamFoundation.Build.targets file.

This one can be used only with .vsmdi files, and this differing number four in my demands.

3) Writing task of my own, and make all my dreams come true. And this is what I did.

The task has all the functionality that MSTest command line tool has.

How to use the task?

Import the task in you .proj file:

<UsingTask TaskName="Dobkin.Common.Tasks.MSTest"AssemblyFile="D:\MyFolder\Dobkin.Common.Tasks.dll"/>

And call the task:

<ItemGroup Condition="$(ProjectName) == 'Project1'">

        <Tests Include="c:\Project1\Project1.BL.Test.dll"/>

        <Test Include="c:\Project1\Project1.Dal.Tests.dll"/>


 <ItemGroup Condition="$(ProjectName) == 'Project2'">

        <Tests Include="c:\Project2\Project2.BL.Test.dll"/>

        <Test Include="c:\Project2\Project2.Dal.Tests.dll"/>

        <Test Include="c:\Project2\Project2.Utils.Tests.dll"/>


And that’s it. For now on, every new test project or even a whole new solution, you will add, you have to change only this file (for new solution of course you have to import this file first)

Documentation of how to use the task is included in the attachment.


הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *

83 תגובות

  1. Yosi Taguri16 בדצמבר 2007 ב 8:09

    putting the path to an assembly in an MSBuild file is considerd a bad practice since it will work only on your machine.

    Having a relative path or registering it in the gac( which I don't like also) will work.

  2. Nati Dobkin16 בדצמבר 2007 ב 20:31

    I am totally agreed with Yossi. The example that I showed is for proof of concept only. Defiantly the best practice is to write relative path to you working directory.

    Thanks Yossi for the correction.

  3. Mladen Trifunovic24 באפריל 2009 ב 19:05

    I don’t see any tags. So how does it execute task?

  4. exercise sitting9 בספטמבר 2010 ב 11:00

    I don't know if you've heard of Varolo yet, but it is a way to make money by watching commercials online. It is invite only so I'm extending my invitation to everyone that wants to take advantage the new advertising method that Varolo is offering and to make some extra cash. If you visit Varolo, you can see their video on more of what I'm talking about, how it works and the potential you have to make some decent money. Don't take my word for it, check it out for yourself.


  5. ToratordDrale25 בפברואר 2011 ב 22:10

    ThePigsSayMoo|Well, she only saved him coz Draco was alive…..and Harry did save his life twice that night.п»ї


  6. Anon5 במאי 2011 ב 21:00

    How about removing the spam comments?

  7. meraj10 ביולי 2012 ב 15:59

    while running test using first option i got below warning

    Warning: Test Run deployment issue: The assembly or module 'msshrtmi' directly or indirectly referenced by the test container 'e:\source\taf\user management\test\bin\debug\saras.usermanagement.test.dll' was not found.

    what to do.

  8. Flores18 ביולי 2012 ב 12:27

    you can always count on search results marketing when you would along the lines of to promote products online.

  9. Burkholder30 ביולי 2012 ב 20:17

    seafoods have been great because that they are really
    tasty, i think that almost all seafoods have been super duper

  10. Matlock31 ביולי 2012 ב 21:30

    i use google when i would for instance to do some spanish translation, its first-rate for wide-ranging spanish

  11. Lau11 באוגוסט 2012 ב 6:27

    You have brought up a very first-class points , appreciate it for the post.

  12. East11 באוגוסט 2012 ב 6:40

    I always visit new blog everyday and i found your blog.

  13. Robertson11 באוגוסט 2012 ב 6:58

    I gotta favorite this internet site it seems very helpful very helpful

  14. Petit11 באוגוסט 2012 ב 7:07

    His idyllic existence is one day broken when a team of heavily armed
    men turn his house into dust in an attempt to kill him, it is up to
    him then and a few old friends to use and figure out to that the bottom of that the unknown
    kill squad.

  15. Kidd11 באוגוסט 2012 ב 7:14

    Do you write more It merely required a few moments to see your entry and
    so have an awareness that I recognize most people miss out on.
    Getting more people to join that the discussion is typically a great thing.

  16. Freed11 באוגוסט 2012 ב 7:16

    I actually love the method you discuss this kind of topic.

  17. Waldron11 באוגוסט 2012 ב 22:26

    Thank you for your content very helpful for me,
    an alternative webpage I found and hope you like it

  18. Ferrell11 באוגוסט 2012 ב 22:32

    You need to take part in a tournament for starters of that the finest domains on-line.
    Ill recommend this blog!

  19. Duckett11 באוגוסט 2012 ב 23:18

    I am pleased, I have to state. Actually not often
    will i come across your blog that is certainly every educative as well as enjoyable, and let me tell you, you have got strike that the actual toenail about the head.
    That the idea will be exceptional the difficulty is something that doesnt sufficient folks are speaking wisely about.

    I am extremely comfortable which i stumbled all through
    this kind of in my search for a very important factor relating to this.

  20. Stillwell12 באוגוסט 2012 ב 1:29

    I was just browsing for related blog posts for my project research and I happened to get yours.

    Thanks for the useful info!

  21. Gerald12 באוגוסט 2012 ב 1:40

    You commit an error. Write to me in PM, we will discuss.

  22. Neely12 באוגוסט 2012 ב 1:50

    Just where maybe you have discovered that the source intended for this post Great studying I have subscribed for your blog feed.

  23. Prater12 באוגוסט 2012 ב 17:09

    i am using infolinks and chitika and i think infolinks have
    that the best payout .

  24. Culp12 באוגוסט 2012 ב 17:13

    Sometimes the easier to only take one step back again and also know
    that few people gives your beliefs

  25. Graf12 באוגוסט 2012 ב 17:30

    This one page has a tendency to redeem much page views.
    Exactly how do you market it

  26. Krebs12 באוגוסט 2012 ב 18:20

    Spot on with this writeup, I really suppose
    this website needs far more consideration. Ill most likely be once more to
    read much more, thanks for the information.

  27. Maynard12 באוגוסט 2012 ב 20:16

    I appreciate your time and effort allocated to this article, bad i had to spend this long
    to search out it on that the other hand because that they say top quality is difficult to get.
    Continue the first-class work.

  28. Scoggins12 באוגוסט 2012 ב 21:08

    “Hello, you site is very funny he told me to cheer up

  29. Anonymous12 באוגוסט 2012 ב 22:55

    most broadband services have been crappy, that they cant maintain high data transfer rates

  30. Hardaway13 באוגוסט 2012 ב 3:32

    This web site is my intake, very first-class style and Perfect articles.

  31. Callaway15 באוגוסט 2012 ב 15:52

    This sort of thing needs to happen! Simply letting the quota happen isnt acceptable.
    This will help you stay above that the curve.

  32. Wirth24 באוגוסט 2012 ב 17:15

    Okegreat to seek out out, there were without a doubt a number of points that I hadnt thought
    of before.

  33. Ambrose25 באוגוסט 2012 ב 23:01

    Loving the info on this website, you have done outstanding job on the blog

  34. Noble31 באוגוסט 2012 ב 7:01

    lip gloss with olive oil is the best because it can moisturize your lips as well,

  35. Sikes1 בספטמבר 2012 ב 1:59

    Is there a toughest thing in that the world To believe.

  36. Jamieson1 בספטמבר 2012 ב 6:04

    bar stools that are made from stainless steel have been
    that the best as they dont tarnish often

  37. Mcintosh1 בספטמבר 2012 ב 21:03

    bed sheets that have been made of flannel fabric
    are the best type of bed sheets

  38. Omalley4 בספטמבר 2012 ב 12:33

    i can see tons of free music online but most of them are pirated.

  39. Erickson4 בספטמבר 2012 ב 12:50

    divorce is of course one of the worst thing someone to could experience then again
    you could find out over it

  40. Amato4 בספטמבר 2012 ב 14:04

    i would love to munch so a whole lot of italian foods, italian foods are that the
    best in my opinion and they are very tasty.,

  41. Ault4 בספטמבר 2012 ב 14:23

    Hello! Do you know if they make any other plugins to safeguard against hackers Im kinda paranoid about losing everything Ive worked hard on.
    Any tips

  42. Collier4 בספטמבר 2012 ב 14:45

    LCD TVs can actually save you from high electricity bills and office space

  43. Eubanks5 בספטמבר 2012 ב 21:08

    Thanks for that the great post on your blog, it actually gives me an insight
    on this topic.

  44. Paige5 בספטמבר 2012 ב 23:46

    Hi, do you have a facebook fan page for the blog

  45. Willett6 בספטמבר 2012 ב 0:31

    You need to join in a contest along the lines of of the greatest domains via
    the internet. Ill suggest this blog!

  46. Machado6 בספטמבר 2012 ב 10:24

    There are pros and cons to taking this approach. However you
    possibly can make the child custody hearing work to your advantage by knowing what the court expects out of
    you because a parent.

  47. Sherrod6 בספטמבר 2012 ב 10:26

    Remarkable page! I seriously had our checking.
    Im hoping to read effortless things a large amount more on your side.
    In my opinion that you have exceptional awareness
    and even prospect. Now i am quite pleased within this guidance.

  48. Gann17 בספטמבר 2012 ב 14:29

    When I originally commented I clicked that the Notify me when new surveys have been added
    checkbox and after this each time a comment is added I determine
    four emails concentrating on that the same comment.
    Is there in any means you are able to eliminate me out
    of that service Thanks!

  49. Fernandes19 בספטמבר 2012 ב 18:04

    I was reading through some of your blog posts on this site and I think this web site is really instructive!
    Keep on putting up.

  50. Spinks19 בספטמבר 2012 ב 18:12

    This site is actually a walkthrough it is
    that the details you wanted about it and didnt be acquainted with who to question.
    Glimpse here, and youll certainly find it.

  51. Ritter21 בספטמבר 2012 ב 12:53

    seafoods are great as they are actually tasty, i
    think that almost all seafoods have been super duper tasty

  52. Oconner21 בספטמבר 2012 ב 14:46

    Well, Objective, im not so i are in agreement with all in
    this article, however you do make a important comprehension with this issue.
    I may instruct myself

  53. Conn21 בספטמבר 2012 ב 17:19

    I Love LENKA and i always play her music on my iPod. her music is sort of unique:

  54. Hastings21 בספטמבר 2012 ב 18:21

    That the climax by far has the best parts of the film.

  55. Lumpkin21 בספטמבר 2012 ב 19:27

    Tremendous guide! Make took pleasure in the exact looking at.
    I hope to find out much out of your company. My wife and i you
    might incredible knowledge together with view.

    What i’m particularly fascinated in this area material.

  56. Portillo21 בספטמבר 2012 ב 19:36

    Thank you for sharing your stuff on blog. it’s probably that we have similar interests.
    something are very useful to me.

  57. Benson21 בספטמבר 2012 ב 20:25

    my dad is really a massage therapist and he can really
    relieve small pains and injuries“

  58. Woodley21 בספטמבר 2012 ב 23:58

    Votre étude alors voilà quelques satisfaisants sujets de discussion cependant reste sceptique de la
    sincérité de vos taux affichés ici dans ce petit paragraphe

  59. Matias22 בספטמבר 2012 ב 3:41

    I really love the line of attack you discuss this kind of topic.

  60. Gilmer22 בספטמבר 2012 ב 4:18

    Which is some inspirational stuff. Never knew that opinions could be this varied.
    Thanks for every one of the enthusiasm to supply
    such tips here.

  61. Stallworth22 בספטמבר 2012 ב 4:55

    I tried to submit a comment earlier, although it has not shown up.
    I think your spam filter may possibly be broken

  62. Brandon22 בספטמבר 2012 ב 5:09

    well of course, everyone loves to discover rich
    then again not everyone would love to do challenging

  63. Christman22 בספטמבר 2012 ב 13:27

    Awesome! I thank you your contribution to this matter.
    It has been insightful. my blog maple syrup

  64. Wilkerson22 בספטמבר 2012 ב 13:37

    Thanks for taking the time to post this data. I am recently one of your most
    passoniate followers. I have your RSS feed in my iphone
    and will check back regularly.

  65. Roberts22 בספטמבר 2012 ב 14:39

    Very significant info!Perfect just what I was searching for!

    . “Success is that old ABC — ability, breaks, and courage.
    by Charles Luckman.

  66. Holly22 בספטמבר 2012 ב 16:18

    divorce is of course one of that the worst thing someone to could experience on that the other hand you could determine over it

  67. Batson22 בספטמבר 2012 ב 17:12

    This was really a fascinating matter, I am very lucky to have the ability to come to your blog and I will
    bookmark this page so that I might come back
    one other time.

  68. Mitchel22 בספטמבר 2012 ב 17:21

    Nearly the whole thing seems to jump off
    the screen, however at the same time that the film doesnt actually have any other standout moments where the
    effect is utilized in a system that actually wows it's audience.

  69. Whitfield22 בספטמבר 2012 ב 17:50

    MrNewbieVideo New News With Five New Apps, Zoho Is Now That the
    Largest Developer On The Google Apps Mar

  70. Avery22 בספטמבר 2012 ב 18:06

    I am pleased that I detected this web site, precisely the right information that I was looking for!

  71. Leatherman22 בספטמבר 2012 ב 18:10

    Some genuinely great information , Glad I discovered this.

  72. Elkins25 בספטמבר 2012 ב 14:43

    Wonderful I enjoyed seeking through your page.
    I think you are truely remarkable.

  73. Corey29 בספטמבר 2012 ב 16:30

    not everyone would need a nose job conversely my girlfriend actually needs some rhinoplasty coz her nose is quite crooked.

  74. ilawzixi@gmail.com13 בנובמבר 2012 ב 22:11

    This is a wonderful internet page, could you be interested in performing an interview about just how you designed it? If so e-mail me!

  75. Musselman26 בנובמבר 2012 ב 11:06

    I will tell your friends to visit this site. .Thanks for the

  76. Ferro28 בנובמבר 2012 ב 17:04

    I notice there is certainly quite a large amount of spam on this
    blog. Do you may need help cleaning them up? I might help between courses!

  77. Bailey29 בנובמבר 2012 ב 10:11

    Someone Sometimes with visits your site regularly and recommended it
    to me to read as well. The system of writing
    is great and the content is top-notch. Thanks for the insight you give out
    the readers!

  78. Ray12 בדצמבר 2012 ב 9:17

    Actually there is a better way to do this and that is by using batching.


    < ?xml version="1.0" encoding="utf-8" ?> "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"



  79. Liles25 בדצמבר 2012 ב 11:04

    i have seen several cellular browsers and used some of them, they
    have been still a bit slow;;

  80. Gerber9 בפברואר 2013 ב 1:06

    What a lovely blog page. I will definitely be back again.
    Please keep writing!

  81. ejjfaxjkbpx@gmail.com31 במאי 2013 ב 3:54

    I visited various websites but the audio quality for audio songs present at this site is really fabulous.

  82. scoocairrizix29 בספטמבר 2013 ב 8:33

    高品質と独創的で創造的なデザインのため、バーバリーハンドバッグは絶大な人気を得る。複数の色、サイズと形状は、財布、トートバッグやバーバリーのハンドバッグの他のタイプで利用できるそこにすべての女の子の夢です。他の人がある日、彼らは本物を買う余裕だろうことを期待して、安価な模造品と自分自身を感謝しなければならない間、いくつかの女性はさえ、財布のミニコレクションを持っている。 [url=]ヴィトン 財布[/url]
    シャネルは、新しいダリアバッグシリーズの打ち上げは、古典的なファッショナブルで、まだ目に見える控えめなエレガントな女性の香りで、ブランドの古典と極めて簡潔なスタイルに従う。シャネルダリアのユニークな黄金のロックで肯定バッグのシリーズ、および利用可能な複数のスタイルとサイズを持っている。 2012年秋洞のシャネルダリアシリーズ新しい袋黄色、青2色、または一部がモダンでエレガントで、ふくらはぎのデザインを使用して残りの部分も見フロントひしゃくカバー、バッグ本体としてpythonの皮膚の選択に追加します。