views:

1012

answers:

1

This is a two part question.

Background: We moved our C# application from VS2005 to VS2008 and in the process moved the application from .net 2.0 to .net 3.5. The transition went smoothly except for Unit Tests.

First: Is the unit test framework based off Visual Studios or .NET?

Second: This question is derived from the issues we have with the unit tests. We have internal classes that need accessors in order to unit test them. When the application was in VS2005, all the accessors were auto created from right clicking on the desired class and selecting "Create Private Accessors" - this Accessor was placed in VSCodeGenAccessors.cs. Now after the migration to VS2008 and .net 3.5, the accessors are placed within a newly created folder "Test References" and for each accessor a file is created ( .accessor)

How, for consistency sake, do I get the accessors to be generated into VSCodeGenAccessors.cs.

Thanks!

+2  A: 

To answer your first question, the unit test framework is a part of certain versions of Visual Studio. AFAIR:

  • Visual Studio 2005 Team System
  • Visual Studio 2008 Team System
  • Visual Studio 2008 Professional

Regarding your second question I'm afraid I can't be of much help - I consider it a worst practice to unit tests internals, so I have no experience with the Private Accessors.

Mark Seemann
Mark, Why do you consider unit testing of internals a worst practice?
Eric U.
The most important aspect of a unit test suite is to serve as a regression test suite that acts as a safety net for when you refactor code. Internal code is not part of the API, so by testing internals directly you constrain yourself unnecessarily much because every time you change an internal method you break the tests. It's an old unit testing debate. Note that I'm not saying that internal code should not be *covered* by tests, but rather that coverage should happen through the public API.
Mark Seemann