среда, сентября 28, 2011

SharePoint 2010 unit testing in Visual Studio 2010

Бля ну что за лажа с шарпоинт, точнее даже не с ним :) (не кидайте камнями, решение внизу)

Вдруг выяснилось, что нельзя написать ms test targeted to .net 3.5 в Visual Studio 2010, чтобы написать парочку тестов, связанных с sharepoint 2010.

В конечном итоге так и придется использовать какие-нить тулзы типа nUnit...

Ладно, в любом случае в процессе гуглинга надыбал интересную фишку, а именно, все же можно заставить ms test выполняться в x64 mode.

Подробности здесь
http://msdn.microsoft.com/en-us/library/ee782531.aspx

что удивительно, описание в картинках, вот так бы почаще :)

Достучаться до этого диалога можно, находясь в контексте ms тестового проекта:

 


Как выяснилось, решение все же есть:

 

http://msdn.microsoft.com/en-us/library/gg601487.aspx

Testing SharePoint 2010 Applications

The capabilities listed above also enable you to write unit tests and integration tests for SharePoint 2010 applications using Visual Studio 2010 Service Pack 1. For more information about how to develop SharePoint 2010 applications using Visual Studio 2010, see SharePoint Development in Visual Studio, Building and Debugging SharePoint Solutions and Verifying and Debugging SharePoint Code by Using ALM Features.

Limitations

The following limitations apply when you re-target your test projects to use the .NET Framework 3.5:

In the .NET Framework 3.5, multitargeting is supported for test projects that contain only unit tests. The .NET Framework 3.5 does not support any other test type, such as coded UI or load test. The re-targeting is blocked for test types other than unit tests.

Execution of .NET Framework 3.5 tests is supported only in the default host adapter. It is not supported in the ASP.NET host adapter. ASP.NET applications that have to run in the ASP.NET Development Server context must be compatible with the .NET Framework 4.

Data collection support is disabled when you run tests that support .NET Framework 3.5 multitargeting. You can run code coverage by using the Visual Studio command-line tools.

Unit tests that use .NET Framework 3.5 cannot run on a remote machine. 

 

В описании сервис-пака:
http://support.microsoft.com/kb/983509

Basic Unit Testing support for the .NET Framework 3.5
In Visual Studio 2010 SP1, you now have the functionality to test your applications that target the .NET 

Итак, поехали, сервиспак радостно качаем отсюда:

http://www.microsoft.com/download/en/confirmation.aspx?id=23691

Теперь выставляем targetting framwework в .net 3.5, хост выполнения теста в x64 mode:

Наслаждаемся:


Будут вопросы, пишите :) Будет время, отвечу :)