[Qgis-developer] Python unit testing for QGIS

Tim Sutton lists at linfiniti.com
Sun Jul 22 15:26:00 PDT 2012


Hi Folks

Yes I know I am becoming something of a unit testing freak, but I am
10 000% convinced we really need to get a good test suite if we plan
to be a viable option for 'enterprise adoption' and generally not
wasting time trying to figure out what works and what doesnt.

Anyway, I have added the capability to add python tests to the CTest
suite (you know when you run make test / check / Experiemental).

I think building a python test suite is a no-brainer - it is where the
largest amount of developer activity happens and we should always know
that third party tools are working.

The nice thing is that you now don't need to be a C++ guru to write
tests. I am going to write proper detailed documentation on how to add
a new python test, but early adopters can check out the sample I added
here:

https://github.com/qgis/Quantum-GIS/commit/b702d3ca9f1e577c1efd57decab972300de3b085#L4L-1

There are a few things that I would still like to resolve:

* you probably will need to set QGISPATH env var to match your CMake
install prefix
* you will probably need to set you LD_LIBRARY_PATH to your qgis libs dir
* currently I don't have 'in build dir' testing working

example session:

export LD_LIBRARY_PATH=/usr/local/qgis-master/lib/
export QGISPATH=/usr/local/qgis-master/
ctest -R App -V


----------------------------------------------------------------------------------------------------------
UpdateCTestConfiguration  from
:/home/timlinux/dev/cpp/Quantum-GIS/build-qt-creator/DartConfiguration.tcl
Parse Config file:/home/timlinux/dev/cpp/Quantum-GIS/build-qt-creator/DartConfiguration.tcl
 Add coverage exclude regular expressions.
 Add coverage exclude: /CMakeFiles/CMakeTmp/
 Add coverage exclude: .*/Testing/Utilities/.*
 Add coverage exclude: .*/Utilities/.*
 Add coverage exclude: .*/Code/Wrappers/SWIG/otbApplicationPYTHON_wrap.*
 Add coverage exclude: .*/Code/Wrappers/SWIG/otbApplicationJAVA_wrap.*
UpdateCTestConfiguration  from
:/home/timlinux/dev/cpp/Quantum-GIS/build-qt-creator/DartConfiguration.tcl
Parse Config file:/home/timlinux/dev/cpp/Quantum-GIS/build-qt-creator/DartConfiguration.tcl
Test project /home/timlinux/dev/cpp/Quantum-GIS/build-qt-creator
Constructing a list of tests
Done constructing a list of tests
Checking test dependency graph...
Checking test dependency graph end
test 22
    Start 22: QGisApp

22: Test command: /usr/bin/cmake "-P"
"/home/timlinux/dev/cpp/Quantum-GIS/build-qt-creator/tests/src/python/QGisApp.cmake"
22: Test timeout computed to be: 1500
22:
22: src/providers/ogr/qgsogrprovider.cpp: 1576: (createFilters) Driver count: 52
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver REC for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver Memory for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver PCIDSK for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver GPSTrackMaker for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver VFK for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver PGDump for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver GPSBabel for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver SUA for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver OpenAir for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver PDS for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver WFS for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver HTF for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver AeronavFAA for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver Geomedia for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver EDIGEO for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver GFT for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver SVG for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver CouchDB for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver Idrisi for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver ARCGEN for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver SEGUKOOA for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver SEGY for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver ODS for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver XLSX for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver ElasticSearch for file filters.
22: src/providers/ogr/qgsogrprovider.cpp: 1779: (createFilters)
Unknown driver PDF for file filters.
22: src/providers/sqlanywhere/qgssqlanywhereprovider.cpp: 2299:
(providerKey) Returning provider key sqlanywhere
22: src/providers/sqlanywhere/qgssqlanywhereprovider.cpp: 2308:
(description) Returning provider description SQL Anywhere data
provider
22: src/providers/sqlanywhere/qgssqlanywhereprovider.cpp: 2299:
(providerKey) Returning provider key sqlanywhere
22: Got bus address:
"unix:abstract=/tmp/dbus-3rQEstL3DZ,guid=7777982fa9944d2ecd8abc3d000000b4"
22: Connected to accessibility bus at:
"unix:abstract=/tmp/dbus-3rQEstL3DZ,guid=7777982fa9944d2ecd8abc3d000000b4"
22: Registered DEC:  true
22: .F
22: ======================================================================
22: FAIL: testValidThemeName (__main__.TestQGisApp)
22: That can set the app to use a valid theme
22: ----------------------------------------------------------------------
22: Traceback (most recent call last):
22:   File "/home/timlinux/dev/cpp/Quantum-GIS/tests/src/python/test_qgisapp.py",
line 22, in testValidThemeName
22:     assert myExpectedResult == myResult, myMessage
22: AssertionError: Expected:
22: gis
22: Got:
22: default
22:
22:
22: ----------------------------------------------------------------------
22: Ran 2 tests in 0.001s
22:
22: FAILED (failures=1)
22: Application state:
22: Prefix              : /usr/local/qgis-master
22: Plugin Path         : /usr/local/qgis-master/lib/qgis/plugins
22: Package Data Path   : /usr/local/qgis-master/share/qgis
22: Active Theme Name   :
22: Active Theme Path   : :/images/themes//
22: Default Theme Path  : :/images/themes/default/
22: SVG Search Paths    : /usr/share/qgis/svg/
22: /home/timlinux/.qgis/svg/
22: /usr/local/qgis-master/share/qgis/svg/
22: User DB Path        : /usr/local/qgis-master/share/qgis/resources/qgis.db
22:
22: Application state:
22: Prefix              : /usr/local/qgis-master
22: Plugin Path         : /usr/local/qgis-master/lib/qgis/plugins
22: Package Data Path   : /usr/local/qgis-master/share/qgis
22: Active Theme Name   : default
22: Active Theme Path   : :/images/themes/default/
22: Default Theme Path  : :/images/themes/default/
22: SVG Search Paths    : /usr/share/qgis/svg/
22: /home/timlinux/.qgis/svg/
22: /usr/local/qgis-master/share/qgis/svg/
22: User DB Path        : /usr/local/qgis-master/share/qgis/resources/qgis.db
22:
22:
22: CMake Error at QGisApp.cmake:18 (MESSAGE):
22:   Segmentation fault
22:
22:
1/1 Test #22: QGisApp ..........................***Failed    0.68 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.69 sec

The following tests FAILED:
	 22 - QGisApp (Failed)
Errors while running CTest
----------------------------------------------------------------------------------------------------------

I look forward to contributions, though maybe just experiment a little
first until I format the test coding standards etc in the docs. As
part of the World Bank/AIFDR funded work that Marco and Radim are
doing, any python bindings or required python functionality will have
tests created for them too to verify that the functionality is
working.

Regards

Tim

-- 
Tim Sutton - QGIS Project Steering Committee Member (Release  Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Visit http://linfiniti.com to find out about:
 * QGIS programming and support services
 * Mapserver and PostGIS based hosting plans
 * FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================


More information about the Qgis-developer mailing list