Edgewall Software

Visual studio (ms build tools) integration with bitten

This is more of working draft.

You should set up the bitten-slave environment with C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat or equivalent for your visual studio setup (this one is for vs 2008)

You should probably do a batch file for invoking bitten-slave like this one

call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"

bitten-slave https://www.eaxmple.org/projects/my_project/builds 

Sidenote: if you do not add call before the vcvarsall your batch will exit before running bitten-slave

Build

Your build step should look something like

    <sh:exec executable="msbuild" args="project.sln /t:rebuild"/>

see  http://msdn.microsoft.com/en-us/library/ms164311.aspx for other msbuild options

Running mstest

    <sh:exec executable="mstest" args="/testmetadata:Project.vsmdi "/>

This executes all the tests in your project (TODO: test it without the /testlist:listname argument) Also it's highly probable that you don't want all tests runned (I do a lot of manual UI tests, wich require user interaction, not a good practice but...), so you should add a test list in visual studio ide (double click on the vsmdi, test lists, right click, new test list, add your tests there) and use this command instead

    <sh:exec executable="mstest" args="/testmetadata:Project.vsmdi /testlist:<list_name>"/>

see  http://msdn.microsoft.com/en-us/library/ms182489.aspx for more mstest options

Running NUnit

I don't use NUnit, but still this should be added for complete reference.

XSLT

You apply this xslt to the trx output of mstest. Be sure to check the vs namespace in line:

      xmlns:vs="http://microsoft.com/schemas/VisualStudio/TeamTest/2006"

against the xml namespace in the trx file, as it may get changed with any update of vs (probably won't but still) or with a diffrent version (ie teamsuite)

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:vs="http://microsoft.com/schemas/VisualStudio/TeamTest/2006"
                >

  <xsl:template match="/">
    <unit_tests>
      <xsl:apply-templates />
    </unit_tests>
  </xsl:template>
  <xsl:template match="//vs:Results/vs:UnitTestResult" >
    <test>
      <status>
        <xsl:if test="@outcome = 'Passed'">success</xsl:if>
        <xsl:if test="@outcome != 'Passed'">failure</xsl:if>
      </status>
      <fixture>noname</fixture>
      <type>test</type>
      <name>
        <xsl:value-of select="@testName" />
      </name>
      <stdout>
        <xsl:value-of select="vs:Output//*" />
      </stdout>
    </test>
    </xsl:template>
</xsl:stylesheet>