qtqt5qt-creatorqtestlib

Qt creator and unwanted automatic prefix for a filename


How can I disable automatic "tst_"-prefix for a cc-filename, when creating unit test subproject in Qt creator?

test case name

Unwanted prefix for a filename

Thanks.


Solution

  • Most of these setup wizards are created with a json config and templates, so they are pretty customizable.

    Look in your QtCreator install folder in the following path: share\qtcreator\templates\wizards\. The Auto Test project wizard is in autotest subfolder. I would make a copy of this folder and rename it. You could just edit the existing one, but it will probably be replaced at next Creator update.

    You'll find a wizard.json file in there. At the top is an options array, and in there are templates for the file names. You'll see the tst_ prefix on a few entries.

            {
              "key": "TestCaseFileWithCppSuffix",
              "value": "%{JS: 'tst_' + value('TestCaseName').toLowerCase() + '.' + Util.preferredSuffix('text/x-c++src') }"
            }
    

    Then you can simply delete the prefix and save the file.

    For more gory details, see the QtCreator docs Adding New Custom Wizards.

    PS. This might be obvious to some, but for completeness...

    If you do copy the wizard to a new folder, I think you'll need to change one line in the json config, and want to change another.

        "id": "R.AutoTest",
        "trDisplayName": "Auto Test Project",
    

    The id needs to be unique, and the trDisplayName probably should also be so you don't confuse it with the included wizard. The id also defines the sort order (the "R." is arbitrary, used for sorting). You can also delete the included wizard but again I think that would only last until the next QtC update. There's no other way to disable them permanently AFAIK.

    Lastly I would consider putting my custom wizards in the user config folder as described in the "Locating Wizards" part of the docs (there will already be a ton of config stuff in that location, so it's hard to miss).