【问题标题】:How to create UI in C++ visual [closed]如何在 C++ 视觉中创建 UI [关闭]
【发布时间】:2015-04-16 05:04:05
【问题描述】:

我是 C++ 和 Visual Studio 的新手,谁能帮我创建一个满足以下要求的 UI?

要求:有一个包含 10 个测试用例的 .txt 文件。在 UI 中,我(测试人员)应该能够选择要运行的测试用例。

【问题讨论】:

  • 请说明您想要什么样的用户界面。 GUI(图形用户界面)允许使用鼠标选择单选按钮,或控制台应用程序(文本用户界面)只是输入数字(或字母)进行选择?
  • 带有测试用例的txt文件的结构是什么?测试用例是一个数字,还是一行中的一组数字,还是其他什么?
  • 该testlist.txt文件看起来像这样:01_DVBT_Short_A7_SensHigh.txt 02_DVBT_Short_A7_SensLow.txt 03_DVBT_Short_A1_CRHigh.txt 04_DVBT_Short_A1_CRLow.txt 07_DVBT_Short_A11_AWGN_4QAM.txt 08_DVBT_Short_A11_AWGN_16QAM.txt 09_DVBT_Short_A11_AWGN_64QAM.txt 11_DVBT_Short_A10_CoChannel.txt 跨度>
  • 每个测试用例文件都在做一些操作,我的要求就像 TESTCASENAME [YES/NO] 如果我们选择是,testcasename.txt 文件将被执行(我不知道哪个适用于此应用程序 GUI/控制台应用程序建议我哪一个最适合我的要求)
  • 所以一个测试用例是用文件名定义的。以及如何在测试中使用此文件名?解释一下,txt文件可以做哪些操作?文件名作为参数提供给某些函数,或者您的程序应该打开文件(例如,选择第 3 个测试用例时为 03_DVBT_Short_A1_CRHigh.txt)并对该文件的内容执行一些操作以执行测试?

标签: c++ visual-studio


【解决方案1】:

尝试使用MFC 项目。您可以在 GUI 工具箱中找到下拉菜单。 进一步了解MFC

参考这个 - https://www.youtube.com/watch?v=6hSYZdvQ3s4&index=1&list=WL

【讨论】:

    【解决方案2】:

    考虑使用命令行界面的可能性,如下模板所示:

    #include <iostream>
    #include <fstream>
    #include <string>
    using namespace std;
    
    int main(int argc, char* argv[])
    {
        // check that parameter is given in command line when program is run
        if(argc != 2) // if number of parameters is insufficient 
        {   // explaine and stop
            cout << "Please, run a program with parameter: name of file with testcases" << endl;
            cout << "For example:" << endl << " " << argv[0] << " tests.txt" << endl;
            return 1;
        }
        // try to open file with test cases
        ifstream testfile;
        testfile.open(argv[1], ifstream::in);
        if( !testfile.is_open() )
        {
            cout << "ERROR: File " << argv[1] << " cannot be open!" << endl;
            return 2;
        }
        // read test cases from file
        string testCaseName;
        char answer;
        while( getline(testfile, testCaseName).good() )
        {
            if(testfile.eof())
            {
                break;
            }
            if(testCaseName.length() == 0)
            {
                continue;
            }
            cout << "Would you like to execute testcase " << testCaseName << " ? (Y/N): ";
            cin >> answer;
            if( answer == 'Y' || answer == 'y')
            {
                cout << "Test execution... " << endl;
                // run test case
                // . . .
                // report test results
                // . . .
            }
    
        }
        return 0;
    }
    

    要使用此类程序运行测试,您应该在命令行中输入:

     programname test_file.txt
    

    【讨论】:

    • 请解释为什么投反对票?
    猜你喜欢
    • 2015-10-12
    • 2012-10-13
    • 1970-01-01
    • 1970-01-01
    • 2010-12-19
    • 2011-09-18
    • 2016-03-28
    • 2015-08-11
    • 2012-07-07
    相关资源
    最近更新 更多