Add Fakes Assembly does nothing and does not create Fakes folder

fauzan-msft 0 Reputation points
2024-02-23T17:39:44.49+00:00

Hello, I am trying to use Microsoft Fakes and am following instructions on this page: Use shims to isolate your app for unit testing

I opened the Solution Explorer and expanded the references section of my unit testing project. I then right clicked on a referenced project (part of the same solution) I want to fake and clicked on "Add Fakes Assembly".

User's image

The Visual Studio status bar changes to show "Processing fakes configuration" for a minute, and then goes back to ready.

User's image

However, I can't see any Fakes folder, git status returns empty. Also VS does not recognize ShimsContext as valid.

User's image

I am using VS 2022 Enterprise:

User's image

Is there any thing which I could be missing?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,631 questions
Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
329 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 25,806 Reputation points Microsoft Vendor
    2024-02-26T03:57:36.2866667+00:00

    Hi @fauzan, 

    Welcome to Microsoft Q&A! 

    Does it occur in other reference assemblies? 

    Please ensure the referenced project is correctly loaded and builds successfully. 

    You can update your VS2022 to the latest version and manually delete the .vs, bin and obj folders.

    Then, rebuild the solution and check it again. 

    You can also create a new test project and re-add the project reference, then, check if the “Add Fakes Assembly” works. 

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.  

    0 comments No comments