Forum Discussion

Kateryna's avatar
Kateryna
Contributor
12 years ago
Solved

Stop TestComplete Suite execution using C# code

Hello,



How can I stop TestComplete Suite execution using C# code? This is how my code looks like:

object



 



 



TestCompleteObject = null;



System.Diagnostics.



 



Process rfp = new System.Diagnostics.Process();




string args = @"C:\AutomatedTests\Test\3.2SR1\SystemSetup\SystemSetup.pjs -r -e -SilentMode";




string SystemSetup = @"C:\Program Files (x86)\Automated QA\TestComplete 8\Bin\TestComplete.exe";


string TCProgID = "TestComplete.TestCompleteApplication.8";



rfp = Process.Start(SystemSetup, args);

rfp.WaitForExit(1000 * 60 * 60 * 3);



if (rfp.HasExited == false)



{ rfp.Kill();}



But if I Kill the process project suite log won't be saved. How can I stop execution and close Test Complete instead of killing the process?

 


 



 




 


           



 





 




  • Hi Kateryna,



    Do you mean that you want to stop the test as when clicking the Stop button in the TestComplete IDE? This isn't possible using command-line automation - you need to run TestComplete via COM or use the Connected Application technique instead. Please see examples in the Working With TestComplete via COM - Overview article.



    When using COM automation, you can stop tests using the IntegrationObj.Stop method, in Connected Applications - using Connect.StopTest.

3 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Kateryna,



    Do you mean that you want to stop the test as when clicking the Stop button in the TestComplete IDE? This isn't possible using command-line automation - you need to run TestComplete via COM or use the Connected Application technique instead. Please see examples in the Working With TestComplete via COM - Overview article.



    When using COM automation, you can stop tests using the IntegrationObj.Stop method, in Connected Applications - using Connect.StopTest.
  • Hi Kateryna,

    I'm not sure to understand your question : did you want to stop TestComplete from an external application or your application under test ?

     

    If you want to interrupt tests for a reason or another, you may look this subject and its sub subjects.



    The C# Script instruction

    Runner["Stop"](true);

    will stop the current test.

    I guess you may set a project variable to decide if following test must run or not.



    Best,

    Christophe
  • No, I want to stop execution of the whole suite, not just the current test. And I need to do this from external application.

    I found something similar here but when I write like that:


    string TCProgID = "TestComplete.TestCompleteApplication";

     rfp = Process.Start(SystemSetup, args);   

    TestCompleteObject = Marshal.GetActiveObject(TCProgID);




    I get COMException : "Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))"