Re: Mock Testing of Grilo Plugins



On Fr, 2012-08-03 at 12:05 +0100, Bastien Nocera wrote:
> On Thu, 2012-08-02 at 17:51 +0200, Jens Georg wrote:
> > On Do, 2012-07-26 at 16:01 +0200, Víctor M. Jáquez L. wrote:
> > 
> > > As Jens already said, get_url_now() has two implementation which is chosen in
> > > compile time, given the available libsoup version.
> > > 
> > > Hence, it would be possible to add a third implementation, chosen at compile
> > > time by the unit tests.
> > 
> > While this approach works great simulation-wise, this seems to be
> > slightly more difficult as the things to be tested live outside of
> > grilo's source tree, such as grilo-plugins.
> 
> Personally, I would implement this so:
> - Don't make the plugin developers have to write any different code, it
> should be completely transparent to them

Agree.

> - Make it a run-time switch, an envvar seems like something innocuous
> enough to use
> - Add a capture mode (running in this mode, the GrlNetWc would keep a
> disk copy of everything it downloads), GRL_WEB_CAPTURE_DIR=...

Ah, Good point!

> - Make it easy to construct fake data (this is the data I want for this
> URL).

We've routed for a keyfile that would basically look like this:

[default]
version=1
ignore-query-variables=true

[http://some/url]
data=some_url_content.txt
additional-option=foo

[http://some/url/other]
data=some_url_other_content.txt
another-option=bar

Which is easy to edit and read.

> Drilling down a bit more into Mathias' ideas, I would either make the
> existing network code into a subclass (and move the current
> implementation into its own subclass as well), or simply put the code
> into helpers with if's around in the main code.

So move GrlNetWc to an real (as in GObject) abstract class, having a
factory method to hand out the proper implementation.

Well you'd still need to #ifdef/conditionally compile the soup-stable
vs. soup-unstable code as that can't really live together. soup-stable
is also possible when soup-unstable is available, but not the other way
round, at compile-time.



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