Running unit tests on Team Foundation Server (TFS) builds

后端 未结 3 969
攒了一身酷
攒了一身酷 2020-12-13 19:17

What are the steps to get Team Foundation Server running unit tests when a given build runs?

What are the caveats / pitfalls / workarounds a dev or sysadmin should

相关标签:
3条回答
  • 2020-12-13 20:06

    http://msdn.microsoft.com/en-us/library/cc981972(v=vs.90).aspx

    I like this defination as it gives you a complete 'walkthrough' from Creating the Project Creating the Unit Test Project To configuring Team build to use it Unit Test

    0 讨论(0)
  • 2020-12-13 20:08

    If you don't want to use test configs (A Pain in the ass to manage) just run all the test in a .dll by adding this to the build config:

    <ItemGroup>
        <TestContainerInOutput Include="MyProject.UnitTests.dll" />
    </ItemGroup>
    

    The whole process is smooth and fairly simple. You can inspect the unit tests that filaed on the build server by opening the test result file locally (a bit of a pain) but generally you'll just run the unit tests locally and you can see the results immediately.

    If you are used to NUnit, you may opt to sort the tests by classname, it gives a similar view.

    Careful with code coverage, it makes complete copies of your binaries on compile. If your binaries are sufficiently large and you compile often, it will eat through drive space quickly.

    0 讨论(0)
  • 2020-12-13 20:14

    it depends on which version of TFS you are running, so I will assume it is 2008.

    Firstly, you must have Team Edition for Testers installed on the computer that will act as your build agent, as stated in How To: Create a Build Definition

    There are a couple of ways to tell Team Build to run tests for your build.

    1. Unit tests can be run from a defined Test List within the Solution being built. This list is referenced by the build definition and all tests within the chosen list(s) are executed. More info here
    2. WildCard test exectution is also available by defining a wildcard mask (i.e. Test*.dll) that instructs Team Build to run any tests present in assemblies that match the mask. This is done when defining the build definition as well.

    Things to note:

    If you intend to use the wildcard method and want to enable code coverage for your test configuration, you must add the following to your build definition file to enable it.

    <RunConfigFile>$(SolutionRoot)\TestRunConfig.testrunconfig</RunConfigFile>
    

    See my previous question on this for more info here

    0 讨论(0)
提交回复
热议问题