VSTS构建测试执行阶段无法找到Coded UI测试求助
Alright, let's figure out why your Coded UI tests aren't showing up in your VSTS build's Test Runs. I've gone through your error message and build config, here are the key fixes to try:
1. Fix Your Test Assembly Filter (It's Too Broad)
Right now, your test assembly selection is scanning every DLL in your repo—including all the NuGet packages and non-test SDKs like Newtonsoft.Json or Azure Storage. That's why you see all those irrelevant paths in the error, and the test runner is getting confused.
Update your Test Assemblies setting in the Visual Studio Test task to target only your actual test DLL. For example:
**\FullSite1.dll !**\obj\** !**\packages\**
Or if you use a naming convention like *Tests.dll for test projects, use:
**\*Tests.dll !**\*TestAdapter.dll !**\obj\** !**\packages\**
The !**\packages\** part ensures we ignore all the NuGet DLLs that don't contain tests.
2. Lock the Test Platform to Visual Studio 2017
Coded UI tests are tied to specific Visual Studio versions, and using "Latest" for the test platform might be picking up a newer version that doesn't have the right test discoverer for your 2017 tests.
In the Visual Studio Test task:
- Head to the Advanced tab
- Set Test platform version explicitly to
Visual Studio 2017 - You already checked "Test mix contains UI Tests"—good, keep that enabled, it tells the runner to look for UI-specific tests
3. Make Sure Your Compiled DLL Actually Has Tests
The error says it's scanning D:\a\3\s\FullSite1\bin\Debug\FullSite1.dll—let's confirm this DLL has your test method:
- Add a Publish Build Artifacts task after your build step to publish the
bin\Debugfolder - Download that artifact to your local machine, then open Visual Studio > Test Explorer > Load Tests from this DLL
- If no tests show up here, your build isn't compiling the test correctly:
- Double-check your test class has the
[TestClass]attribute - Your test method must have the
[TestMethod]attribute - Ensure your test project is set to build in your solution's configuration
- Double-check your test class has the
4. Match Build Config to Your Local Setup
In your Visual Studio Build task, make sure the Platform and Configuration match what you use locally (like Any CPU and Debug). If the build uses a different config, the compiled DLL might not have the test metadata the runner needs.
5. Double-Check NuGet Dependencies
Ensure your NuGet Restore task is pulling in all the required packages for Coded UI tests—things like Microsoft.VisualStudio.TestTools.UITesting. If these packages are missing, the test runner won't recognize your Coded UI tests even if they're in the DLL.
内容的提问来源于stack exchange,提问作者Sohel

