« TDD: I just can't stop talking about it! | Main | Moving Up In The World »

August 30, 2007


Dan MacDonald

I'm not sure how your testing, but could you make your unit tests in a partial class (of the class you are testing) so that they are in a separate code file that you can leave out of the final build, but they have full access to all the internals of the class you are testing? (during development)

Andy Larder

You should look into friend assemblies in C#, which allow an assembly to give internal access to another assembly.


What you're looking for is the InternalsVisibleTo assembly level attribute. I generally have my assembly and then a seperate test assembly. I give my assembly an internalsvisibleto attribute identifiying my test assembly, this at least gives my test assembly access to internal methods such that you don't have to make things public you wouldn't normally expose...

On the other hand if you wanted to be crafty a bit of reflection would work too, if I recall the test framework in VS Team Suite provides this functionality for you.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment

Your Information

(Name is required. Email address will not be displayed with the comment.)

Jamie's Bragging Rights

  • Spider-Man 2
    The best superhero games of all time Game Informer
    Top five games of all time Yahtzee Croshaw
    Top five superhero games of all time MSNBC
    Top 100 PS2 games of all time Official Playstation 2 Magazine
    1001 Games You Must Play Before You Die Nomination for Excellence in Gameplay Engineering Academy of Interactive Arts & Sciences
  • Schizoid
    Penny Arcade PAX 10 Award
    Nominated for XBLA Best Original Game
    Nominated for XBLA Best Co-Op Game