Forum Discussion

mgroen2's avatar
mgroen2
Super Contributor
9 years ago

Running Powershell script from TestComplete test

Hi,

I need to run powershell scripts after my tests has ended. I use Keyword testing as much as possible.

 

Does anybody have any experience with that? How to do this? Best practices, etc.

 

Any comment, tips, are welcome.

 

Mathijs

 

  • You can run powershell scripts as TestedApps. Add it as a generic windows application, here's an example I setup with a simple powershell script, all the powershell script does is use Copy-Item to copy a folder or file to another folder or file (both file paths are passed in as command line arguments through TestedApps).

     

     

    Then just run and close the TestedApp from the keyword test like you normally would.

     

     

     

    • mgroen2's avatar
      mgroen2
      Super Contributor

      ghuff2 thanks for the info.

       

      It works, you suggested it.

       

      However, it would be even better if the command line parameters could be variable, so that I can run Powershell as a TestedApp, with parameters to be used as Command line parameters. 

      Example:

      I have multiple Powershell scripts which need to be run. Now I need to define a TestedApp for each Powershell script to be run. It would be easier if I can only define 1 Powershell as TestedApp and when calling it in my test I use the script to be run as a parameter.

       

      Don't know if this is already implemented in TestComplete?

       

      • ghuff2's avatar
        ghuff2
        Contributor

        You can set the command line args through TestComplete scripting, see this article. So you'd just have powershell.exe be saved as the TestedApp and then set the command line arg for a specific script before running the TestedApp.