3

I am having this wierd problem with MOQ Unit tests.

I have around 636 unit tests written using MOQ Framework in VS 2012. When I run them project-wise and/or individually, they pass successfully. but whenever I select Run-All they fail randomly showing different errors.

Most of the methods show IO.FileNotFoundException.

I looked Here here and here but no clue yet.

Edited:

I solved the problem of FileNotFoundException using DeploymentItem[] attribute.

But still one of the project is failing when RunAll. exception tells - "Cannot convert, incompatible types" on of the properties.

Community
  • 1
  • 1
deathrace
  • 827
  • 3
  • 20
  • 42
  • Do you have anything in the config files of individual test projects that the failing tests need? When you run all tests in a solution it isn't able to pick these up per project. – Jamie Humphries Jan 28 '15 at 09:52
  • Are you using ReSharper? I have had a similar problem to this while running all with ReSharper. – Matt Jan 28 '15 at 10:03
  • Could you provide more detail on the exceptions you're getting? Do you know which file can't be found? Also, are your tests being run synchronously or asynchronously? – Chris Mantle Jan 28 '15 at 10:05
  • 3
    Do your tests do any set up and tear down of resources? If you have multiple tests accessing the same file it could cause issues especially if any of them change it. It might be an idea to post the code of one of the tests which occasionally fails. – Andy Nichols Jan 28 '15 at 11:23
  • I solved the problem for FileNotFoundException. I used DeploymentItem["NeededProject.dll"]. it worked – deathrace Jan 29 '15 at 06:04

1 Answers1

0

seems like I missed using DeploymentItem["NeededProject.dll"] for each unit test class. Its working fine now. :)

deathrace
  • 827
  • 3
  • 20
  • 42