8

When using the Visual Studio Test task in Release Management, the release always returns:

No test assemblies found matching the pattern

currently Test Assembly is set to: **\*test*.dll;-:**\obj\**

I have tried multiple defaults like $(System.DefaultWorkingDirectory), etc.

The documentation I've been able to find is either not current with the existing layout of tasks, (such as the Publish Build Artifacts screen no longer containing the Contents box), is for the on premise Visual Studio 2015, or related specifically to the Build.

I've read and attempted the following:

UPDATE: I added a step to the build to Copy and Publish the test.dlls. They are now located. They all fail, due to missing other code, but they are located.

UPDATE II: My 3_Run_Tests.log file contains the following clues:

Error calling Initialization method for test class ... To run tests that interact with the desktop, you must set up the test agent to run as an interactive process.

Test Run deployment issue: The assembly or module ... directly or indirectly referenced by the test container ... was not found.

Because of the above, I am going to accept @eddie-msft's answer.

Community
  • 1
  • 1
Joshua Drake
  • 2,704
  • 3
  • 35
  • 54
  • Can you confirm that the test assemblies are being published as artifacts and are getting pushed to the `$(Agent.ReleaseDirectory)` folder? – Daniel Mann Jan 05 '16 at 18:06
  • 1
    Which test framework? – jessehouwing Jan 05 '16 at 18:38
  • Whatever the default is with the **Visual Studio Test** task. – Joshua Drake Jan 05 '16 at 19:33
  • @JoshuaDrake The question was "What testing framework are your tests using?" – Daniel Mann Jan 05 '16 at 19:38
  • @DanielMann and that is the answer, I have not done anything aside from adjust the value in the **Test Assembly** textbox. The **VSTest version** is **Latest**. I guess in this case the MS testing framework might be the appropriate reply, but since it has all been subsumed into VS or RM, I hardly think of it as a Framework any more. – Joshua Drake Jan 05 '16 at 19:45
  • @DanielMann Am I simply going about this too naively, do I need to setup test machines and the rest in order to fun anything outside of the Build process? – Joshua Drake Jan 05 '16 at 19:46
  • Can you share the test failure log? – Eddie Chen - MSFT Jan 06 '16 at 02:22
  • @JoshuaDrake: can you clarify what the first "UPDATE" means ("added a step to the build to Copy and Publish the test dlls". I can't get my tests found, but I've never seen this copy and publish step documented by Microsoft as part of unit testing in VSTS. What did you copy and where did you copy it to? – PatrickSteele Nov 03 '16 at 16:02
  • @PatrickSteele I added the [Copy and Publish](https://www.visualstudio.com/en-us/docs/build/steps/utility/copy-and-publish-build-artifacts) step to the Build definition. – Joshua Drake Nov 04 '16 at 15:35
  • @JoshuaDrake, thanks. Yeah, I tried that. Set the Copy Root to the entire folder where my unit tests exist. When I look at the log of that step running, I can see it copying all my .cs files, but it never copies any DLLs. Very odd (and frustrating!). I can see in the build process logs that the unit test compiled, but I can't find the right set of switches/knobs to have VSTS find and execute the tests. Thanks for the follow-up on such an old question! :) – PatrickSteele Nov 04 '16 at 15:39

2 Answers2

5

You need to make sure that the complied file of the project which you'd like to test is also been copied and published to the same path with Test Assembly. The test will fail if only Test Assembly is copied.

I assume you are working on a C# project, in the step to copy test assembly, you can set the copy content as this:

**\YourTestProjectName\bin\$(BuildConfiguration)
Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
  • This answer addresses both the original issue, and the updates. The original issue was simply not copying the test dlls, however, that in itself is not enough as Eddie - MSFT points out. – Joshua Drake Jan 06 '16 at 15:05
  • Can you please add example of how-to copy this assembly? I mean, I tried different options with `Copy Root`, `Content`, `Artifacts name` and `type` but still without success. – Vlad Nov 23 '16 at 05:27
  • @VladislavKasianenko This depend on your project and settings. You can check from the build log to see where are these files placed. And according to your description, are you using "Copy and Publish Artifact" task? It is used to publish build files. If you want to copy files from one path to another path, you need to use "Copy Files" task. – Eddie Chen - MSFT Nov 23 '16 at 05:35
  • @Eddie-MSFT I have a solution with 8 projects. I need **Project**, **Project.Web** and **Project.Web.Tests**. 1 - restore nuget, 2 - build Project, 3 - build Project.Web, 4 - build Project.Web.Tests, 5 - Copy Files, 6 - Test Assemblies. While build, I have this **MSBuild Arguments**: `/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"`; Copy - Source: `$(build.sourcesdirectory)`, Contents: `**\bin\$(BuildConfiguration)\**`, Target: `$(build.artifactstagingdirectory)`. – Vlad Nov 23 '16 at 07:44
  • @Eddie-MSFT **Test Assembly**: `**\$(BuildConfiguration)\*test*.dll;-:**\obj\**` – Vlad Nov 23 '16 at 07:47
  • @Eddie-MSFT Generaly, I have folders like this: SolutionFolder\(Project, Project.Web, Project.Web.Test, etc...), test .dll on local machine can be found here: `SolutionFolder\Project.Web.Tests\bin\(Release|Debug)\Project.Web.Tests.dll` – Vlad Nov 23 '16 at 07:49
  • @VladislavKasianenko What's the result you get with this settings? – Eddie Chen - MSFT Nov 23 '16 at 07:51
  • @Eddie-MSFT `Copy Files to: $(build.artifactstagingdirectory): found 0 files`, `Test Assemblies **\Release\*test*.dll;-:**\obj\**: No test assemblies found matching the pattern: '**\Release\*test*.dll;-:**\obj\**'.` – Vlad Nov 23 '16 at 08:02
  • @VladislavKasianenko That's weird. The settings should works. Did you check the build logs to see if the test assembly is generated during the build? Can you share the entire build logs if possible. – Eddie Chen - MSFT Nov 23 '16 at 08:06
  • @Eddie-MSFT Can we discuss this anywhere else where I can post my logs and screenshots? – Vlad Nov 23 '16 at 08:10
  • @VladislavKasianenko You can email me: eddche@microsoft.com – Eddie Chen - MSFT Nov 23 '16 at 08:28
  • Changing `any cpu` to `anycpu` helped me. – Vlad Nov 23 '16 at 09:05
0

I have been having a similar issue. Multiple projects in build and the test file would not be found.

No test assemblies found matching the pattern *test*.dll;-:\obj**

Fix: added additional build step "build solution" and "Copy Files to". This build was pointed to VS solution file with automated test. "Copy Files to" was left at default

jislanddev
  • 11
  • 3