In the past I've been asked to test a complex Qlikview Project with lots of variables, events and macros.
Manual testing was becoming too complex and boring, so I helped adding a bit of rspec to the mix.
I've been using rspec to test almost everything in the past few years and this was an intriguing new testing challenge.

step 0 - install the tools

  • install Qlikview Desktop 11
  • install ruby (my swiss-army integration tool of choice)
  • install bundler gem install bundler
  • create the project folder
mkdir rspec_for_qlik
  • create a file named Gemfile into the project folder with the following content:
source ''

gem 'ruby-ole'

group :development, :test do
  gem 'rspec'

  • install all the dependencies
cd rspec_for_qlik && bundle install
  • create the project directories mkdir src && mkdir lib && mkdir spec

step 1 - build a small automation lib

Before even starting to build the actual tests, I wrote a small DRY library.
It's very easy to integrate win32 ole api with ruby (and even more easily java libraries with jruby indeed) as you can see in the following example:

    # coding: utf-8
    require 'win32ole'
    class QlikDoc < Object
      attr_accessor :qv_app, :qv_doc
      def init()
        @qv_app ="QlikTech.QlikView")
      def open_doc(file_path)
        @qv_doc = qv_app.openDoc(file_path)
      def close_doc()
      def quit()
      def set_variable(variable_name, variable_value)
        qv_variable = @qv_doc.Variables(variable_name)
        qv_variable.SetContent(variable_value, true)
      def get_variable(variable_name)
        qv_variable = @qv_doc.Variables(variable_name)
      def set_selection(field_name, field_value)
      def clear_selection(field_name)
      def press_button(object_id)

save the example above in a file called lib\qlik_doc.rb

step 2 - setup a simple test

Let's create our first test.
First of all create or copy the qvw file you want to test in src\testbed.qvw.
n.b. in order to pass the test, the testbed.qvw file must contain a variable named testbed_variable

Next create a rspec test in spec\qlik_spec.rb with the following content:

    # coding: utf-8
    require './lib/qlik_doc'
    RSpec.describe QlikDoc, :type => :model do  
      before(:all) do
        @q =
      before(:each) do
      it "should set and read a variable named testbed_variable" do
      	expect(@q.get_variable('testbed_variable')).to eq('successful')
      after(:each) do
      after(:all) do

step 3 - run the test!

To run the test and check the result it's a matter of typying rspec.
The output should be

Finished in 2.98 seconds (files took 0.45292 seconds to load)
1 example, 0 failures

post scriptum

All the files above are available in github
In the git project there is no testbed.qvw file. You will find, instead, a folder called testbed-prj, containing the "xml" content of the original file. In order to create the correct testbed.qvw file, just create a new and empty qvw file named testbed.qvw, open it and save it (under the hood, Qlikview will load the content from the testbed-pro folder...).


front image by Mars Hill Church Seattle