I have a question is that I can't test the Private or Protect method
which is belongs to a Class.
Currently, I am using the Reflector to invoke private method, it looks
like can't cover all methods and lines.
The greatly appreciate if you could provide me the solutions.
Thank you.
Jenson
Generally, you want to write your Unit Tests so they test a class'
public interface - or, more accurately, the behavior promised by the
interface. The idea is that you can change the implementation (= private
methods) and the tests will still pass as long as the behavior exposed
by the class stays the same. Otherwise, unit test might become an
obstruction to change instead of an enabler.
If you can't stimulate a specific code path through public methods, it
must be a dead code path that can be eliminated.
If it becomes to difficult to find out how to stimulate a specific code
path, try writing more and smaller classes.
:)
> Jenson
>
>
-Markus-
Thank you for resolve my doubts.
Regards
On Dec 31, 7:19 pm, Markus Ewald <cy...@nuclex.org> wrote:
> On 12/31/2009 10:54 AM, jenso...@gmail.com wrote:> Hi All,
-Markus- -- You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group. To post to this group, send email to nunit-...@googlegroups.com. To unsubscribe from this group, send email to nunit-discus...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/nunit-discuss?hl=en.
-- Gerard Meszaros 1-403-827-2967 or m...@gerardmeszaros.com Author of the Jolt Productivity Award winning book "xUnit Test Patterns - Refactoring Test Code". Learn more at http://xunitpatterns.com/index.html