QTest: add custom parameters
Unsolved
General and Desktop
-
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. -
Hi,
Can you show how your test is written ?
-
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); }