0

我正在为 VS2008 sln 文件运行 Team City Pro (v4.0.2 build 8222)。

现在我面临一个问题,即没有为测试项目中的私有访问器生成自动生成的代码,并且由于无法找到那些(自动生成的)类而导致编译错误。

构建运行器是默认的 sln2008。

有什么配置需要改吗?我检查了 VS 构建日志,它没有显示自动生成的类的任何 msbuild 条目。自动生成类的 DLL 就在那里。

注意:我知道测试私有方法是进行单元测试的最佳方式。

4

2 回答 2

0

AFAIK,TeamCity 不使用 msbuild 实用程序来构建解决方案。你不想问 TeamCity 开发人员吗?

于 2009-06-14T17:14:53.210 回答
0

确保 MSBuild 版本为 3.5,MSBuild ToolsVersion 为 3.0 或 3.5。 替代文字 http://www.deploylx.com/so/tcbuildrunner.jpg

使用 MSBuild 运行 NUnit 测试

    <PropertyGroup>
        <NUnitCommandArgs Condition="'$(NUnitCommandArgs)' == ''">$(NUnitCommandArgs) /noshadow /timeout=30000</NUnitCommandArgs>
        <NUnitCommandArgs Condition="'$(TestGroupInclude)' != ''">$(NUnitCommandArgs) /include=@(IncludeTestGroups, ',')</NUnitCommandArgs>
        <NUnitCommandArgs Condition="'$(TestGroupExclude)' != ''">$(NUnitCommandArgs) /exclude=@(ExcludeTestGroups, ',')</NUnitCommandArgs>
    </PropertyGroup>

    <ItemGroup>
        <NUnitAddinFiles Include="$(teamcity_dotnet_nunitaddin)-2.5.0.*" />
    </ItemGroup>

    <ItemGroup>
        <NUnitRuntimeFiles Include="$(ToolsPath)\nUnit\nunit.core.dll" />
        <NUnitRuntimeFiles Include="$(ToolsPath)\nUnit\nunit.core.interfaces.dll" />
        <NUnitRuntimeFiles Include="$(ToolsPath)\nUnit\log4net.dll" />
    </ItemGroup>

    <Target Name="RunUnitTests" >   

        <Message Text="Include=@(IncludeTestGroups), Exclude=@(ExcludeTestGroups)" Importance="High" />

        <MakeDir Directories="$(ToolsPath)\addins" />

        <Copy SourceFiles="@(NUnitAddinFiles)"
              DestinationFolder="$(ToolsPath)\addins"
              />

        <Copy SourceFiles="@(NUnitRuntimeFiles)"
              DestinationFolder="$(TestFolder)" />

        <Exec
            WorkingDirectory="$(ToolsPath)\nUnit\"
            Command="&quot;$(ToolsPath)\nUnit\nunit-console-x86.exe&quot; &quot;%(TestAssemblies.FullPath)&quot; $(NUnitCommandArgs)"
            />

    </Target>
于 2009-06-17T08:55:57.607 回答