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

Nathan Broadbent nathan.f77 at xxxxx
Wed Nov 30 06:36:53 UTC 2011


(continued from github - https://github.com/geany/geany/pull/15)

> I don't think any of Geany's developers will argue that having some sort of unit testing would be a good idea, especially for the plugin API, but mainly it boils down to:
>
> 1) What framework to use (Geany is written in plain C).


>From the Stack Overflow question "Is Google Test OK for testing C
code?" (http://stackoverflow.com/a/6218365/304706) :

It is pretty common to test C code using a C++ testing frameworks,
even the leading book on the subject
(http://pragprog.com/titles/jgade/test-driven-development-for-embedded-c)
follows this approach. I have used googletest extensively in the past
to unit test C code and can recommend it.

I have written a blog post about it that might be useful:
http://meekrosoft.wordpress.com/2009/11/09/unit-testing-c-code-with-the-googletest-framework/

...

As long as your headers are C++-compatible (not using C++ keywords,
export symbols with correct linkage), it should be fine.


> 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.


> 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.


> 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.


-------------

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.

<editor_rant>

Also to be honest, I'm still a little conflicted with regards to gedit
vs. geany vs. others. Gedit uses GTKSourceView, which has definitions
for many more languages, but their lexers are XML / Regex based. So
they're really slow for larger files, and they don't support code
folding, which I'm starting to get used to. But their community seems
to be a lot bigger, and a little more active.
I also experimented with an editor called 'Redcar' which now appears
to be the worst of both worlds... It uses GTKSourceView, plus the main
editor is written in Ruby... Ruby might be my favorite language, but
it's damn slow.
So yeah, I've tried everything from vim to Eclipse, but so far, only
Geany seems to have the right balance. So I'd like to put in some
effort to make this editor better - after all, I'm going to be using
it for 8 hours a day.

</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.



More information about the Devel mailing list