Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.NET+;TeamCity:未编译专用访问器_.net_Unit Testing_Mstest_Teamcity - Fatal编程技术网

.NET+;TeamCity:未编译专用访问器

.NET+;TeamCity:未编译专用访问器,.net,unit-testing,mstest,teamcity,.net,Unit Testing,Mstest,Teamcity,我正在为VS2008 sln文件运行Team City Pro(v4.0.2 build 8222) 现在我面临一个问题,测试项目中的私有访问器的自动生成代码没有生成,并且由于无法找到那些(自动生成的)类而导致编译错误 构建运行程序是默认的sln2008 是否需要更改任何配置?我检查了VS构建日志,它没有为自动生成的类显示任何msbuild条目。自动生成类的DLL就在那里 注意:我知道测试私有方法是进行单元测试的最佳方式。好的,TeamCity不使用msbuild实用程序来构建解决方案。是否要?

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

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

构建运行程序是默认的sln2008

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


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

好的,TeamCity不使用msbuild实用程序来构建解决方案。是否要?

确保MSBuild版本为3.5,MSBuild ToolsVersion为3.0或3.5。

使用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>

$(NUnitCommandArgs)/noshadow/timeout=30000
$(NUnitCommandArgs)/include=@(IncludeTestGroups,,)
$(NUnitCommandArgs)/exclude=@(ExcludeTestGroups,,)

您能发布一个示例应用程序吗?这些类是如何自动生成的?msbuild脚本中的自定义步骤?@mausch:如果我知道,我不会问这个问题。正如我所说,autogen类没有msbuild条目,.accessor文件不包含任何与生成命令相关的内容。好的,首先我们需要了解一下。这些课程看起来像什么?发布一个小代码片段。@mausch:你真的尝试过为单元测试添加私有访问器吗?哦,我猜你说的是mstest的自动生成代理。我想你应该弄清楚,不是每个人都使用mstest(我不知道),因为它当前正在运行“sln2008”runner,切换到“MSBuild”将删除运行NUnit测试的选项。我们使用MSBuild选项并运行NUnit测试。看一看我为使用MSBuild&TC运行nUnit而添加的代码段。我应该将此代码段添加到哪里?sln文件?它只是一个示例,演示如何从MSBuild脚本调用NUnit。你可以把它放在任何你想要的项目中。如果您打算使用TC来管理构建,学习一点MSBuild将非常有益。