Re: [Vala] [RFC] Testing framework improvements



Hello Julien,

Julien Peeters <jj peeters    > writes:
We made work about that in LibGee. We wrote a TestFixture class which wraps
the TestCase class of GLib.Test namespace and make tests use Vala style
coding.

Our work in only in the master branch of libgee (see tests/testfixture.vala)
for the moment. I have planned to improve this little framework and make it
become an independant library if that will make sense.

I have downloaded libgee and looked at it. Unfortunately it's a different
from what other unit test libraries call a fixture, because in all those
libraries, the fixture is re-created for each test case and deleted again
afterwards.

It should be possible to convert your fixture to behave that way by making
the suite a class variable and placing the add_test calls into the class
constructor.  (The class variables and class constructors are members and
constructor of the meta-object, so they are separate for each subclass). On
the other hand the gir-based approach would still make it nicer to use.

Also now I noticed a problem caused by the generic tests. With explicitly
created fixtures, you can have generic fixtures and set the types as you
wish. But the same would not be possible with introspection-based
construction. So one would instead create subclasses, that would derive using
particular type. And that causes a problem how the runner knows not to
instantiate the base class -- which leads me to believe the fixture should in
fact be an interface, so the test classes can be derived in whatever way one
needs. It makes a lot of sense in other cases too, e.g. if you want to run
the same set of tests against multiple implementations of something.

I advice you to also see and follow this bug report
http://bugzilla.gnome.org/show_bug.cgi?id=590237

I will update it when I test that the gir approach is viable.

Regards,
Jan





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]