Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTest: add custom parameters
Forum Update on Monday, May 27th 2025

QTest: add custom parameters

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 480 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    debian
    wrote on 23 Oct 2018, 13:40 last edited by
    #1

    Hello!
    I use Qt-5.11.1, I write test with QtTest framework and it work fine.
    Now I add command line parametr via QCommandLineParser

    # LD_LIBRARY_PATH=/tmp:$LD_LIBRARY_PATH ./rcu_exclusive_server_test -h
    Usage: ./rcu_exclusive_server_test [options]
    
    Options:
      -h, --help             Displays this help.
      -s, --server <server>  server socket
    

    Unfortunately after running test with new command line it exit with message Unknown option: '-s'

    # LD_LIBRARY_PATH=/tmp:$LD_LIBRARY_PATH ./rcu_exclusive_server_test -s /tmp/vvv
    Unknown option: '-s'
    
     New-style logging options:
     -o filename,format  : Output results to file in the specified format
    .........
    

    How can I add custom parameters to test?
    Thank you and excuse my bad english.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 23 Oct 2018, 21:28 last edited by
      #2

      Hi,

      Can you show how your test is written ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • D Offline
        D Offline
        debian
        wrote on 24 Oct 2018, 07:25 last edited by
        #3

        Hello @SGaist

        int main(int argc, char *argv[])
        {
            QCoreApplication app(argc, argv);
        
            QCommandLineParser parser;
            parser.addHelpOption();
            parser.addOption(
                {{"s", "server"},
                 "server socket",
                 "server",
                 RCU_EXCLUSIVE_SERVER_ADDRESS}
            );
            parser.process(app);
        
            MyClass tc(parser.value("server"));
        
            QTEST_SET_MAIN_SOURCE_PATH
        
            return QTest::qExec(&tc, argc, argv);
        }
        
        1 Reply Last reply
        0

        1/3

        23 Oct 2018, 13:40

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved