[Geany-devel] Unit tests for Geany (continued from Github)

Lex Trotman elextr at xxxxx
Wed Nov 30 07:15:48 UTC 2011


Hi Nathan,

I hope this reply doesn't end up sounding too negative, I even
suggested Geany needed unit testing myself once in the past. ... but

On Wed, Nov 30, 2011 at 5:36 PM, Nathan Broadbent <nathan.f77 at gmail.com> wrote:
[...]
> ...
>
> As long as your headers are C++-compatible (not using C++ keywords,
> export symbols with correct linkage), it should be fine.
>

All Geany is C, not C++, ie no extern C {} anywhere.  Don't know if
this is an issue.

>
>> 2) How do you run unit tests on a live GUI application with no libraries (surely there's a way).
>
> I don't have much experience, so I can't offer any suggestions. But I
> can do the research.

For unit testing I don't think the GUI thing is such a problem
compared to the fact that the sort of application Geany is means that
it has *lots* of global state (all the filetypes, all the open
documents etc) and setting this up right for unit tests is going to be
hard.


>
>
>> 3) Who's going to do it :)
>>
>> If you want to help with this, I'm sure it would be appreciated.
>
> I could help start it off, but it would have to be an on-going thing.
> I wouldn't have the time to sit down and write tests for the whole
> application. Each developer could get into the habit of writing a test
> whenever they change something or add a new feature.

And here lies the biggest problem, for an existing application the
added value is small if only changes get tested, and changes become
very expensive if a full unit test is required for any unit that is
changed.  And what are you going to test against?  There is no
internal specification for Geany's units.


>
>
>> The only real restriction IMO is that it not add any dependencies to the
>> application or build system under normal conditions.  For example, it would be a bummer to make Joe Hacker have to install some exotic
>> unit testing framework libraries just to do a `make && make install`.
>
> I totally agree with not adding dependencies under normal conditions,
> and I don't think that will be an issue if the code is written well.
> Test-driven development often enforces particular design patterns, so
> there will probably need to be some refactoring involved.

Test driven development is fine, thats how I do most of my stuff (in
C++ with my own test harness and -DWITH_UNIT_TESTS) but retrofitting
it to an existing mature application is unlikely to be cost effective.


>
>
> -------------
>
> To be honest, the real reason that I started talking about unit tests,
> is because I really need them in order to write a lexer for scintilla.
> Manual testing for lexers would be a nightmare.

I'm unsure what a test harness would gain you, lets use your favourite
language Ruby, how would you test such a lexer other than feeding it
ruby source and looking at the results?  Which is what opening a Ruby
file does.

>
> <editor_rant>
[...]
> </editor_rant>
>
>
> Cheers!
> Nathan
>
>
> P.S. The documentation needs to be updated for the 'waf' build system,
> in quite a few places, including geany-plugins.

How?

> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel



More information about the Devel mailing list