Integrate Pex with MoQ
Asked Answered
B

2

5

Can anyone point me to a resource that shows an example of how Pex can be used in conjunction with MoQ? Thanks

Bottoms answered 18/6, 2010 at 15:43 Comment(0)
L
5

Pex uses Moles for isolation (mocking). One can still use MoQ alongside Moles. It's actually preferred to use a framework like MoQ for stubbing and mocking when the code can allow for it, leaving only Moles for the stuff MoQ can't isolate (sealed classes, non-virtual methods, private members, etc).

To backup my statements, Peli de Halleux (a member of the Pex and Moles project), mentions doing the same thing over on MSDN forums.

I have been using Moles and you can code with both frameworks in a unit test. But this probably isn't much help as you are asking specifically about Pex, which I haven't tried yet. Is it possible to modify the unit tests Pex creates and add the MoQ code after the fact?

Lithograph answered 27/9, 2010 at 15:11 Comment(1)
4 upvotes when it doesn't answer the question. Hes looking for an example. The problem is that pex will dive into the moq framework, the question is how does this impact on using pex.Tubman
F
2

When writing parametrised Pex tests make sure that when you get those "Uninstrumented methods" related to Moq calls, you can easily click on "Ignore uninstrumented method..." that will add assembly attribute to your test project and it will simply ignore Moq methods thus making them usable in your tests.

I've done it myself and tests run as expected.

Festination answered 1/10, 2010 at 1:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.