none
catch exception and show results after running tests RRS feed

  • Question

  • Hello

    I am new to work on coded-ui, I have created test which running , I am calling them from a button click on win form, Now i need to show results of run tests pass or failed, and exception in case of failure of test.

    this is the structure of project

    Please help me to do this 

    thanks


    Saadie

    Wednesday, September 11, 2019 5:16 AM

All replies

  • Hi Saadia,

    Sorry for delay in reply.

    Do you mean you would like to get test results and display it in a control? Does this results more related to the test's errors that you set or just relate to Visual Studio's error message? Could you please share us with more information and i will research and then test in my side.

    Sorry for this inconvenience and look forward to hearing from you.

    Best Regards,

    Tianyu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, September 11, 2019 12:18 PM
  • The results related to the test infect I want a presentable report at the end all test run, showing every run test with name and the test result whether is it pass or fail and if failed so the failing error message should be there. I want that report should be saved in the system.

    Saadie

    Wednesday, September 11, 2019 12:54 PM
  • Hi Saadia,

    Sorry for delay in reply.

    For your requirement, we recommend that you could use TestContext.CurrentTestOutcome to get the test outcome, please refer the following function:

    public int GetTestOutcome()
    {
          var testOutcome = TestContext.CurrentTestOutcome;
    
          if (testOutcome.ToString() == "Passed")
          {
                //Action
          }
    
          If(testOutcome.ToString() == "Failed")
          {
                //Action     
          }
    }

    To get the results we recommend you could create a process and call process.Start( ) to run vstest.console.exe ( mostly in C:\xxx\vs_enterprise_2019\VS_IDE\Common7\IDE\CommonExtensions\Microsoft\TestWindow )

    Process process = new Process();    
    ProcessStartInfo startInfo = new ProcessStartInfo(runFilePath, s); 
    process.StartInfo = startInfo;
    process.Start();

    then use command:

    cd [Path of your .dll file]

    vstest.console.exe [coded ui test assembly name] /logger:trx; logfilename=[filename].trx to create a .trx result file.

    Hope this could help you.

    Best Regards,

    Tianyu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, September 12, 2019 12:09 PM