Squish/Custom Settings for Test Runs: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(Un-nominate for deletion: Page is no longer a category)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
this page in: [[Category:Tools::Squish::CustomSettingsForTestRunsSpanish|Español]] [[Category:Tools::Squish::CustomSettingsForTestRuns_Italian|Italian]]
{{LangSwitch}}


[[Category:Tools::Squish]]
[[Category:Squish]]
 
= Custom settings for test runs =


In certain test cases, it might be necessary to use custom settings for the application compared to other test cases. This could for example include an application that shows an introductory guide the very first time it is started, to set up some basic settings. This would only work the first time though, as the settings are stored when the test case is finished, preferrably using QSettings.
In certain test cases, it might be necessary to use custom settings for the application compared to other test cases. This could for example include an application that shows an introductory guide the very first time it is started, to set up some basic settings. This would only work the first time though, as the settings are stored when the test case is finished, preferrably using QSettings.
Line 9: Line 7:
But since we can access all of the Qt API from Squish, there is an easy way around this problem! For the specific test case, simply modify the QSettings object for the application. Or more specifically, change the path to where the settings are stored to a temporary directory that you are removing at the end of the test script.
But since we can access all of the Qt API from Squish, there is an easy way around this problem! For the specific test case, simply modify the QSettings object for the application. Or more specifically, change the path to where the settings are stored to a temporary directory that you are removing at the end of the test script.


<code>tempDir = "/tmp/test-settings"<br />QSettings.setPath(QSettings.NativeFormat, QSettings.UserScope, tempDir)</code>
<code>tempDir = "/tmp/test-settings"
QSettings.setPath(QSettings.NativeFormat, QSettings.UserScope, tempDir)</code>


Keep in mind that this call will not modify existing QSettings objects in the application, so this will need to be done before any of those are created.
Keep in mind that this call will not modify existing QSettings objects in the application, so this will need to be done before any of those are created.

Latest revision as of 08:40, 8 December 2018

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

In certain test cases, it might be necessary to use custom settings for the application compared to other test cases. This could for example include an application that shows an introductory guide the very first time it is started, to set up some basic settings. This would only work the first time though, as the settings are stored when the test case is finished, preferrably using QSettings.

But since we can access all of the Qt API from Squish, there is an easy way around this problem! For the specific test case, simply modify the QSettings object for the application. Or more specifically, change the path to where the settings are stored to a temporary directory that you are removing at the end of the test script.

tempDir = "/tmp/test-settings"
QSettings.setPath(QSettings.NativeFormat, QSettings.UserScope, tempDir)

Keep in mind that this call will not modify existing QSettings objects in the application, so this will need to be done before any of those are created.