You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSTS自动化构建中单元测试未执行的技术求助

Troubleshooting VSTS VsTest Task Not Running Unit Tests

Hey there, let's figure out why your VsTest task is starting but not executing any unit tests. Based on the log snippet you shared, here are the most common issues to check and fix:

  • Double-check test assembly matching patterns
    The default testAssemblies pattern (**\*test*.dll;-:**\*TestAdapter.dll;-:**\obj\**) might not match your test project's output DLL. If your test assemblies are named like *Tests*.dll or follow a different convention, update the "Test files" field in the VsTest task to explicitly target them, e.g., **\bin\$(BuildConfiguration)\*Tests.dll.
    To confirm if your test DLLs exist at the expected path, add a temporary Command Line task to run:

    dir $(Build.SourcesDirectory) /s /b *test*.dll
    

    This will list all matching DLLs in your build workspace.

  • Ensure test projects are being built
    Sometimes test projects are excluded from the build configuration. Go to your solution's properties, verify that the test project is checked under the current build configuration (e.g., $(BuildConfiguration)). Also, check the build logs for entries like Building project "C:\agent\_work\1\s\YourTestProject\YourTestProject.csproj"—if you don't see this, the test DLL isn't being generated at all.

  • Align VsTest task configuration with build settings
    Make sure the "Platform" and "Configuration" parameters in the VsTest task match exactly what your build task uses. For example, if your build targets x64 and Release, the VsTest task should use the same values—mismatched settings will lead to the task looking in the wrong folder for test assemblies.
    Also, uncheck the "Skip test runs if no test assemblies are found" option temporarily. If the task can't find any assemblies, this will throw an error instead of silently skipping, which helps pinpoint the issue.

  • Verify test adapter compatibility
    If you're using third-party test frameworks like NUnit or xUnit, ensure the corresponding test adapter NuGet package is installed in your test project:

    • For NUnit: NUnit3TestAdapter
    • For xUnit: xunit.runner.visualstudio
      Outdated or missing adapters will prevent the VsTest task from discovering your tests.
  • Review the full VsTest task logs
    The snippet you shared only shows the task start. Expand all log entries for the VsTest task—you'll likely find detailed messages like "No test assemblies found matching the pattern" or errors loading test assemblies, which are critical for troubleshooting.

内容的提问来源于stack exchange,提问作者Philipp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:11:03