[MonoDevelop] First go at unit tests

Jacob Ilsø Christensen jacobilsoe at gmail.com
Sat Dec 3 04:14:36 EST 2005


On 12/2/05, Lluis Sanchez <lluis at ximian.com> wrote:
>
> Hi,
>
> > Ok, I tried testing the SourceViewTextIterator class in
> > SourceEditorDisplayBinding.cs. The class is private and this turned
> > out to be quite problematic. I had to start up a lot of MD
> > infrastructure in the test to even get this class instantiated. This
> > is a bad smell IMO.
>
> That was expected.


Well, for this particular class maybe it was. But I am sure it is easy to
unit test a lot of other code this way.

>
> > I do not think it is feasible to do it this way. So how do I go about
> > testing this class? I see a couple of options:
> >
> > * Put the test in the class.
> > * Make the class public.
> > * Move the class somewhere else.
>
> None of those options are acceptable.


Could you elaborate on that, please?

>
> > It ought not be so hard to unit test a search algorithm. Maybe the
> > algorithm should be moved somewhere else?
> >
> > Any good ideas out there? :-)
>
> I think that the best solution would be to implement a Tester add-in,
> which once loaded in MD would use the public API to test whatever needs
> to be tested.
>
> You would not directly test the SourceViewTextIterator class, but
> instead you would use the MonoDevelop.Ide.Gui.Search api, which
> internaly relies on that class.


I am not very fond of this approach. First of all I would like to run by
tests as part of the build process. I would not like to have to start
MonoDevelop to be able to run my unit tests. Secondly it might be hard to
test the internals of a class using only some public API.

/Jacob

Lluis.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monodevelop-list/attachments/20051203/781d1719/attachment.html


More information about the Monodevelop-list mailing list