Hi John

On Mon, Jul 11, 2011 at 4:12 PM, John Donovan <[email protected]> wrote:
> With all this talk of unit testing and the benefits gained from it,
> how would I set up my test environment to run the unit tests I have
> developed for my plugin?
>
> For instance, I have a test suite that ensures correct settings are
> written and read via QSettings, but naturally QGIS needs to be running
> for  it to work.

it is not that hard to prepare QSettings to act as if you were inside
QGIS application. This should be sufficient to pretend that your unit
test is actually QGIS:

from PyQt4.QtCore import QCoreApplication
QCoreApplication.setOrganizationName( "QuantumGIS" )
QCoreApplication.setApplicationName( "QGIS" )

A bit harder may be test code using QgisInterface instance -
preferably the code you are going to test should not use that
interface at all, otherwise you would need to create a mock object
implementing the methods you use.

Regards
Martin
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to