Hi Basanta,
Frankly, I would never use a test framework that made me work in the
way you are working! Fortunately, NUnit doesn't require you to work
that way. :-) More inline...
On Wed, Jul 11, 2012 at 5:39 AM, Basanta Padhi
<
basanta...@gmail.com> wrote:
> Hi all,
>
> I am a C# developer and few months before I started implementing NUnit
> in my application for Unit testing. For implementing NUnit I always
> change my code like:
>
> 1) Making all the methods and classes "public"
Many developers are happy to keep things public for testing and work
this way. Since you are changing the methods back to private after
testing, I guess you don't want to do it. I suggest that you
1) Investigate other ways to allow your test methods to access the
production methods they need to call.
2) Consider keeping your code less closed. For example, a
collaborating class and it's methods may be public, while the instance
of that class held by other classes remain private.
> 2) Avoiding return type from a method.
> 3) removing all the parameters from the methods whose implementing
> NUnit
> 4) to removing parameters from the methods whose implementing NUnit I
> am calling them indirectly from another non-parametrized method.
I don't understand why you are doing these other things at all.
> again while going to merge the code I am changing the code according
> to my project requirement like:
>
> 1) making public access modifier to private.
> 2) removing extra methods added for implementation of indirect call of
> parametrized method etc.
If you are doing this, then you are not testing the code you
distribute. Don't work this way. Test the same code that will go into
production, otherwise your application is untested.
>
> Now I can say I am developing the code because I want to implement
> NUnit in my application. Is there any way I can implement NUnit
> without changing my code or I am implementing it in a wrong way.
Unit testing with a proper framework does motivate you to make certain
positive changes to your code, which is a good thing. However, I know
of no framework that would require you to make all the changes you are
making - and certainly not NUnit! Perhaps you should give us some
individual examples of changes you make in separate posts and we can
discuss whether they are really needed.
> Can anybody please suggest me the main benefits of using NUnit in my
> application because currently what ever I am doing by NUnit, that I
> can do without using NUnit also. the difference is only GUI which
> NUnit provides to me. Apart of this most of the things I can do
> without using NUnit also. So what is the need of NUnit implementation
> for Unit testing.
Tests can be written without a framework - or you can create your own framework.
What a framework gives you is a uniform structure for creating and
running tests. It provides a discipline that helps you to test
correctly. When using a TDD approach, it helps the design of your code
to emerge as you work and forces you to use certain best practices in
that design.
Charlie
> --
> You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
1> To post to this group, send email to
nunit-...@googlegroups.com.
>1 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.
>