Device Testing and SharePoint Development

I am interested in writing unit tests for the work of SharePoint that I do. Can anyone suggest practical approaches for implementing unit tests in MOSS?

Please note that any third-party tools should be free (but not necessarily open source); the company in which I work will not pay for additional equipment. In particular, any alternatives to Typemock Isolator for SharePoint will be appreciated.

Thanks, MagicAndi.

+4
source share
5 answers

A controversial alternative for you - do not use mocks!

Instead, do integration testing, because indeed, once you use SharePoint OM, this is what you do.

Put most of your logic in library assemblies that can be run from outside the Context request (overload constructor for passing to HttpContext or SPWeb).

Configure the server / site (it is advisable that you can roll back and create new instances) only for unit tests and run against it. ( VMWare server is free)

If you are performing a continuous build, you should be able to run it automatically and report the results. Alternatively, you can use some of the magic of the open source batch file nUnit or your tool to run tests as soon as the new .dll is copied at the PostBuild stage.

disadvantages

  • You have a bit of work setting up data for your tests (although it is much more than getting bullying working?)

  • Not everything can be tested as follows

  • It may take a little longer to start, but if you work as part of a continuous build, is this a problem?

  • The team requires more discipline so as not to step on other fingers of people.

Benefits

  • Testing against real SharePoint OM with all its incomprehensible inconsistencies and special cases (if you were unkind, you can call them errors;)

  • Who knows what parts of OM’s behavior can subtly change when new service packs / cumulative updates appear, this should help to catch any violations.

  • When SharePoint 2010 appears, you can run your tests against 2007 and 2010, see what has changed, make sure your library works with both versions (if this suits your project)

The compromises for all projects are different, but for my projects I prefer security, knowing that I am testing the real thing - call me old-fashioned if you do!

+4
source

As far as I know, there is not one other than the Typemock Isolator for SharePoint you mentioned. SHarePoint unit testing is known to be different.

+2
source

Andrew Woodward is a big fan of TDD and SharePoint - check out his site here: http://www.21apps.com/agile/unit-testing-sharepoint-getting-into-the-object-model/

+2
source

I recorded web listing in the SharePoint Unit test. It also extends to SharePointDevWiki.com .

+2
source

It seems that Telerik's JustMock can also be used. It can also mock private classes, statics, etc.

+1
source

All Articles