views:

131

answers:

1

I writing a web site that uses Active Directory to validate users. I don't have access to an Active Directory instance that I can edit in any way.

I've heard that some people are using Active Directory Application Mode (ADAM) to create AD data to be used in Unit and Integration Testing.

Has anyone else done this? Are the any good site/blog that tells how to do this? What are the issues? Is this even a good idea?

+4  A: 

I don't think this is a good idea just like reading files or accessing the database in unit tests isn't a good idea. Your tests will become dependent on the state of an external piece of software. Or you will have a lot of setup and teardown code. If you write tests this way you can expect you'll spend a lot of extra time maintaining your test-code. Setting up and maintaining a build server will become harder too and setting up the development environment for new programmers will take more time.

The way to go in cases like this is to set up an adapter class around the infrastructure for calling into AD and to use something like rhino-mocks or another mocking framework to setup a mock-active-directory in your tests. If you're not familiar with mocking it sounds like a lot of work. But in practice it's usually only a couple of lines of code per test.

Mendelt