views:

83

answers:

1

I have created some tests in my WPF application. Right now I am working on testing single components, for example images and text blocks. If I run a single test in my unit tests, they all pass without a hitch. The problem occurs when I try run all the tests, I get the following errors in the tests that create and modify WPF components:

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

I do not create any threads in my tests explicitly, so this is VS08 trying to get clever and bombing my code. I have tried using an application dispatcher but that didn't work...

Any suggestions?

+1  A: 

Perhaps VS08 is running each test in a separate thread? If so, your tests should still work if the are written to be isolated from each other. Make sure that you are not sharing state between tests. Each test should do its own set up/tear down independently of others.

HTH, Kent

Kent Boogaart
No, I don't create any threads and I don't share data between the tests. The problem is that all tests use WPF controls, which need to be edited in the same "gui" thread.
bluebit