Вопрос

I'm writing a project using Win7 x64. Some part of my tests requires using SQLServer CE which only represents support for x86. I'm using Visual Studio 2010 Express and I gotta change platform target for my projects manually editing *.cproj files to run, for example, schema export test (NHibernate). Howcome I run a part of my tests depending on a platform target.

Thanks!

Это было полезно?

Решение

I don't know if there's a built-in mechanism in NUnit to handle this scenario, but at the very least you can use preprocessor directives.

For instance, create a "Debug x86" solution configuration, targeting x86. Then define the DEBUG_X86 conditional compilation symbol (in the properties of the project). Finally, surround your unit test with preprocessor directives:

#if DEBUG_X86
[Test]
public void Test()
{
    // This test will only run when compiled with Debug x86
}
#endif

Edit: Actually, you don't even have to create a new solution configuration, as it's possible to define the conditional symbols depending on the platform (https://stackoverflow.com/a/1313450/869621). So define a WIN32 compilation symbol, and surround your test with it:

#if WIN32
[Test]
public void Test()
{
    // This test will only run when compiled for x86
}
#endif
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top