[QA] API abstraction gem for browser tests

Juliusz Gonera jgonera at wikimedia.org
Wed Feb 5 23:22:37 UTC 2014


Hi,

The QA team has been experimenting with using the MW API to facilitate 
some of the setup for browser tests. It started with a proof of concept 
patch written by Jeff Hall (https://gerrit.wikimedia.org/r/#/c/106548/). 
The patch is now abandoned and the idea is to develop a Ruby gem for 
interacting with the API.

As Jeff told me, Zeljko started working on it at 
https://github.com/zeljkofilipin/mediawiki_ruby_api_client
Since the library is in a very early stage as of now, I decided to also 
take a stab at it yesterday and would present a slightly different, more 
Rubyish and OO-oriented, approach. You can find it here:
https://github.com/jgonera/mediawiki-api

It's just a quick prototype, still requires some cleanup. At the moment 
it is capable only of creating articles, just as Jeff's and Zeljko's 
prototypes. It, however, persists the login information so that you can 
create several pages without repeating the login process. It's only a 
simple example of a benefit of taking a more OO approach. Other benefits 
will be even more obvious if we continue developing it.

It also contains some unit tests in RSpec. Ideally, I would envision a 
gem like this to be something useful not only in our browser tests, but 
also for authors of bots and other tools. It would be great if people 
from outside of the foundation found it useful and could help in 
developing it.

Some other decisions in my prototype:

* Use Faraday (https://github.com/lostisland/faraday) instead of 
RestClient. It's also very popular and supports different backends. 
While this might not be useful for us now, we get it for free and 
someone might use a more concurrent EventMachine backend in future. 
Faraday also has a concept of middleware, which for example gives us 
cookie management for free too.

* Use WebMock (https://github.com/bblimke/webmock) for unit tests. 
Faraday has it's own stubbing mechanism, but it's much less powerful.

Let me know what you think. I'd really like us to work on this together.

-- 
Juliusz



More information about the QA mailing list