問題描述
我正在嘗試為我的項(xiàng)目編寫一個函數(shù)/方法,它會詢問用戶您要運(yùn)行哪些所有測試用例?它看起來像下面...,
I am trying to write a function/method for my project, which will ask to user which all test cases are you going to run? It looks like below...,
Test_Cases_1
|_TestNo1
|_TestNo2....so on
Test_Cases_2
|_TestNo1
|_TestNo2....so on
....
....so on
Test_Cases_N
|_TestNo1
|_TestNo2....so on
那么,現(xiàn)在的挑戰(zhàn)是在運(yùn)行項(xiàng)目時,它應(yīng)該提示我您想要執(zhí)行的所有測試用例是什么?如果我選擇 Test_Cases_1
和 Test_Cases_N
.然后它應(yīng)該執(zhí)行這兩個測試用例,并且應(yīng)該排除 Test_Cases_2 to ....
中的所有其他測試用例.在結(jié)果窗口中,我也想看到 Test_Cases_1
和 Test_Cases_N
的結(jié)果.
So, now the challenge is while running the project it should prompt me what all test cases you would like to execute?
If I select Test_Cases_1
and Test_Cases_N
. Then it should execute these two test cases and should exclude all other from Test_Cases_2 to ....
. In result window also I would like to see the results of Test_Cases_1
and Test_Cases_N
.
所以,如果我看到GoogleTest,有一個方法叫做test_case_to_run_count()
;但是所有的 test cases
都使用 Test_F() 方法注冊.所以,我做了很多分析,但仍然沒有找到任何解決方案.請幫幫我.
So, if I will see the GoogleTest, there is a method called test_case_to_run_count()
;
But all the test cases
are getting registered with Test_F() method.
So, I did lots of analysis, but still did not find any solution.
Please help me.
推薦答案
您可以使用 高級選項(xiàng) 用于運(yùn)行 Google 測試.
You could use advanced options to run Google tests.
要僅運(yùn)行一些單元測試,您可以使用 --gtest_filter=Test_Cases1*
命令行選項(xiàng),其值接受 *
和 ?
用于匹配多個測試的通配符.我認(rèn)為它會解決您的問題.
To run only some unit tests you could use --gtest_filter=Test_Cases1*
command line option with value that accepts the *
and ?
wildcards for matching with multiple tests. I think it will solve your problem.
更新:
嗯,問題是如何運(yùn)行特定的測試用例.將 gtest 與您的 GUI 集成是另一回事,我無法真正評論,因?yàn)槟鷽]有提供您的方法的詳細(xì)信息.不過我相信以下方法可能是一個好的開始:
Well, the question was how to run specific test cases. Integration of gtest with your GUI is another thing, which I can't really comment, because you didn't provide details of your approach. However I believe the following approach might be a good start:
- 通過使用
--gtest_list_tests
運(yùn)行測試來獲取所有測試用例 - 將此數(shù)據(jù)解析到您的 GUI 中
- 選擇要運(yùn)行的測試用例
- 使用選項(xiàng)
--gtest_filter
運(yùn)行測試可執(zhí)行文件
- Get all testcases by running tests with
--gtest_list_tests
- Parse this data into your GUI
- Select test cases you want ro run
- Run test executable with option
--gtest_filter
這篇關(guān)于如何在 GoogleTest 中運(yùn)行特定的測試用例的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!