How do I test WPF components in VS08 unit testing framework?

I have created some tests in my WPF application. I am currently working on testing individual components such as images and text boxes. If I run one test in my unit tests, they all pass without a hitch. The problem occurs when I try to run all the tests, I get the following errors in tests that build and modify WPF components:

"The calling thread cannot access this object because another thread owns it."

I don't create any threads in my tests explicitly, so this is VS08 trying to get smarter and bomb my code. I tried to use Application Manager but it didn't work ...

Any suggestions?

+2


source to share


1 answer


Perhaps VS08 is running each test on a separate thread? If so, your tests should work if they are written to isolate from each other. Make sure you don't use state between tests. Each test should perform its own customization independently of the others.



+1


source







All Articles