Re: Mock Testing of Grilo Plugins



Since GrlNetWc is kind-of abstract wrt get_url_now which has two implementations, soup-stable and soup-unstable, we could perhaps link a special test net lib and simply add a third one, "mock" which is only used in the (in-tree) tests.

 

--

 

Von meinem Nokia N9 gesendet

 


Mathias Hasselmann schrieb am 25.07.12 10:36:

Hi,

Like Jens might have told already we are working on some few Grilo
plugins. To ensure proper quality we also want to mock test this
plugins.

The idea is to have a mock version of GrlNetWc which reads the request
and then creates a fixed response from local files. This responses also
would include erroneous behaviour like timeouts. Another common approach
would be the use of some proxy server, but proxy servers are complex
pieces of software by itself, that need configuration and usually have
their own bugs. Therefore using a proxy server doesn't really fit into
my idea of regression testing.

Now the big question is how to inject the mock instance of GrlNetWc.
I see the following approaches:

1) Add a webclient attribute to GrlMediaPlugin, and let plugins
interested in mock testing use grl_media_plugin_get_webclient() instead
of grl_net_wc_new() to get a web client. This would keep the GrlNetWc
code simple, but would require code changes to plugins interested in
mock testing. Also it'd be trivial to accidentally use grl_net_wc_new()
in new code.

2) Same thing, but use a configuration parameter that tells the web
client's GType.

3) Add the possibility to inject a custom, static request handler into
GrlNetWc. This request handler(s) would catch each request passed to
GrlNetWc and in the case of the mock handler deliver results from local
files. For unknown files they'd just trigger an assertion. This approach
would avoid changes to plugin code, but it would _slightly_ increase the
complexity of GrlNetWc.

4) Use LD_PRELOAD to inject a custom version of GrlNetWc. This approach
would require no modifications at all to library or plugin code, but it
would break in the case of strict kernel policies, at least SE/Linux can
disable LD_PRELOAD. It also risks to break when new API is added to
GrlNetWc without updating the LD_PRELOAD hack. Indisputable it'd be a
hack.

Ciao,
Mathias

_______________________________________________
grilo-list mailing list
grilo-list gnome org
https://mail.gnome.org/mailman/listinfo/grilo-list





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