Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8496145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:46:16+00:00 2026-06-10T23:46:16+00:00

We are using Moles to test some of our legacy code. Currently all of

  • 0

We are using Moles to test some of our legacy code. Currently all of our unit tests pass when run locally using either MSTest or Resharper’s test runner. However when run on the build server (we use a slightly modified TFS 2010 Workflow, using MSBuild and MSTest) all of our Moles tests fail.

When I looked into the cause it was because when the .Moles.dll were generated on the build server, only the Stubs (classes prefixed with “S”) were created but none of the Moles classes (classes prefixed by “M”).

Our code still compiles because one of our developers created a Framework for Moles to simplify the syntax, which uses Expressions and Delegates to make working with Moles feel like working with Moq. The framework uses Reflection to get the Moles version of the methods but because the “M” classes are created it throws a NullReferenceException when trying to get the method because the call to Assembly.GetType returns null.

EDIT: The latest version of the Pex & Moles library are installed on the build server.

EDIT 2: Here is the command line that is in the MSBuild Log

"C:\Program Files (x86)\Microsoft Moles\bin\moles.exe" @"D:\Builds\4\DeltaNet\Run All Unit Tests\Sources\DeltaNet\src\DeltaNetTests\obj\Debug\Moles\moles.args"

And the contents of “moles.args”

Common.Logging.moles;DeltaNetUtils.moles;System.configuration.moles /molesfilesonly /referenceassemblies:"<lots-of-dll-files>" /cachepath:"C:\Program Files (x86)\Microsoft Moles\bin\..\MolesAssemblies" /intermediatepath:"D:\Builds\4\DeltaNet\Run All Unit Tests\Sources\DeltaNet\src\DeltaNetTests\obj\Debug\Moles" /outputpath:"D:\Builds\4\DeltaNet\Run All Unit Tests\Sources\DeltaNet\src\DeltaNetTests\MolesAssemblies" /clrversion:v4.0.30319 /targetframeworkversion:v4.0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:46:17+00:00Added an answer on June 10, 2026 at 11:46 pm

    So, I had another look at this today and I think I came up with the problem and it was depressingly simple.

    I was using moles in 2 different test projects and in one of them I specified exactly which classes I wanted the moles for using the assembly.moles xml file. This one must have been compiled after the one with the bulk of my tests and so it overwrote it in the Binaries directory.

    I removed the specifics from that file and now it looks like my tests are passing and the MXXX types are being created.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Test::Unit::TestCase to write some unit tests. Currently, I have a setup function
We are using moles 0.94 for some tests in our solution. However, every time
Where can I find some GPS unit test data to validate my code? For
For some reason OpenCover is not covering tests using moles on Windows Server 2003
I've just started to use Moles to mock some tricky legacy code. In essence,
I'm using Pex and Moles for my low-level unit testing, but I'm also exploring
I'm using Pex and Moles 0.94.51023.0 with VS2010 SP1. I have successfully made some
I've been using Moles v0.91 for at least a year, with hundreds of tests
I have an issue running some moles tests within Visual Studio 2010. Within a
All, I'm using wordpress with this and for some reason the eventDrop stopped working.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.