XNA module testing, assembly, but errors performed

I am trying to set up some unit tests for an XNA project. After some testing, making sure that the test project is configured to build in the configuration manager and remove references to the XNA content project, I finally got the tests to build.

But tests will still not run for half the time. If I click "start selection" from the test view, I constantly get the error message "There is no such interface (exception from HRESULT: 0x80004002 (E_NOINTERFACE)"). If instead I click the "run all tests in the solution" button, it sometimes starts, but usually it gives me this error: "A specific movie is not valid." if you run all the tests, this works for the first time (it seems that this happens after updating from SVN), after that it stops working.

I found some people with similar problems:

http://connect.microsoft.com/VisualStudio/feedback/details/602985/unit-testing-does-not-work-with-xna-4-0

http://social.msdn.microsoft.com/Forums/en-US/vsunittest/thread/175cb376-9846-40fa-9197-50595cd32200/

But both seemed to die without resolution. Any help would be appreciated.

+4
source share
3 answers

The default XNA solution is not COM visible. It looks like the test framework looks a little better if it is COM-visible. The easiest solution is to open AssemblyInfo.cs, find the line

[assembly: ComVisible(false)] 

And change false to true.

A blog post from Carlos Quintero led me to a fix. This only works in half the cases, and I'm not sure that he is responsible for fixing the problem.

Aaron Stebner states in a forum post that it should not work if the test project refers to ContentProject and refers to the WPDT release notes that agree with this. In my tests, the game project itself should not reference ContentProject so that the tests run successfully every time. I took to remove links for running tests and subsequent replacement. Depending on your test coverage, this may work well or be useless, but it seems like this is the best we can get with a built-in test suite.

+3
source

I know this is annoying, but if you right-click the test project and select Debug->Start New Instance , it should build it and then run the tests. It’s annoying that since you are debugging, any unsuccessful statements suspend execution. However, you may want this to not be a big deal.

+1
source

In some cases, you can select the target code in a regular .net class library project and only reference this class library from the test project. Thus, normal testing functions work very well, since you are not referencing the XNA project.

0
source

Source: https://habr.com/ru/post/1398324/


All Articles