Forum Discussion

sameerjade's avatar
sameerjade
Frequent Contributor
5 years ago

Running tests from TestExecute using batch file

Hi!

I created some smoke tests for our desktop application using TestComplete. I want to integrate these tests with TeamCity as part of continuous integration. I created a batch file which will run my tests using TestExecute silently. When I run my tests from TestComplete manually by right clicking the project suite and selecting "run focussed item", it runs perfectly without any issue. However, my batch file is not running the same way. When I run the batch file by double clicking, it opens a cmd window. After this, sometimes it runs all the tests, sometimes, it runs a few tests and sometimes it does not run any test. In the cmd window, it simply jumps from one test to the next without running them. I do get the "TestExecute has started" pop-up on the bottom right corner at the start of every test though. Attaching below a sample of my batch file and cmd image. Also, attaching screenshot of my TestComplete project with smoke tests. Please advise if I am doing something wrong or any suggestions. Thank you!

 

Batch file:
title Register 360 Smoke Tests
cd C:\svn\TestComplete\Batch_File
echo on

echo ***Starting Register 360 Smoke Tests...***

:: Running smoke tests now

"C:\Program Files (x86)\SmartBear\TestExecute 12\Bin\TestExecute.exe" "C:\svn\TestComplete\DataPrepNew\DPSmokeTest\Reg360\Reg360.mds" /run /project:Reg360 /test:"Smoke Tests|Clean up" /ErrorLog:C:\Reg360_smoke_tests\Export_Logs\SmokeTestsErrorLog /exit /SilentMode /ExportLog:C:\Reg360_smoke_tests\Export_Logs\SmokeTests_log.html /ExportSummary:C:\Reg360_smoke_tests\Export_Logs\SmokeTestsSummary /Timeout:3600

 

"C:\Program Files (x86)\SmartBear\TestExecute 12\Bin\TestExecute.exe" "C:\svn\TestComplete\DataPrepNew\DPSmokeTest\Reg360\Reg360.mds" /run /project:Reg360 /test:"Smoke Tests|SmokeTest01TransgasE57import" /ErrorLog:C:\Reg360_smoke_tests\Export_Logs\SmokeTestsErrorLog /exit /SilentMode /ExportLog:C:\Reg360_smoke_tests\Export_Logs\SmokeTests_log.html /ExportSummary:C:\Reg360_smoke_tests\Export_Logs\SmokeTestsSummary /Timeout:3600

 

echo ***Finished running Register 360 Smoke Tests...***

pause

 

I already tried:

1. Running the batch file as admin

2. Adding delays between the tests

 

Regards,
Sameer

  • Thanks, Alex. I will try what you suggested with the additional quotes. I was able to solve the issue by calling the tasskill command between my tests to force close the TestExecute.exe application. It is probably not a very graceful solution but it is working for now. I will try with additional quotes too.

     

    Regards,

    Sameer

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    I think that the problem is that calls for TestExecute follow one after another. The case is that by default command processor does not wait for the external command/application to complete and proceeds further. TestExecute and TestComplete are a single-instance applications, so they fail to start if already running.

    Try to add 'start /wait' before calls to TestExecute and check if this helps.

     

    • sameerjade's avatar
      sameerjade
      Frequent Contributor

      Hi Alex,

       

      Thank you for your reply. I tried using start /wait at the start of my command (sample attached below). When I run the batch file, it launches TestComplete and then nothing happens; it does not run the tests. Maybe because of '/wait'? Am I using the command correctly?

       

      If I launch TestExecute and then right click the TE icon on bottom right corner and select Run>'myProject' (i.e. without a batch file), it runs my tests ok. Only when I run the batch file, I am running into the issue.

       

      start /wait "C:\Program Files (x86)\SmartBear\TestExecute 12\Bin\TestExecute.exe" "C:\svn\TestComplete\DataPrepNew\DPSmokeTest\Reg360\Reg360.mds" /run /project:Reg360 /test:"Smoke Tests|Clean up" /ErrorLog:C:\Reg360_smoke_tests\Export_Logs\SmokeTestsErrorLog /exit /SilentMode /ExportLog:C:\Reg360_smoke_tests\Export_Logs\SmokeTests_log.html /ExportSummary:C:\Reg360_smoke_tests\Export_Logs\SmokeTestsSummary /Timeout:3600

       

      start /wait "C:\Program Files (x86)\SmartBear\TestExecute 12\Bin\TestExecute.exe" "C:\svn\TestComplete\DataPrepNew\DPSmokeTest\Reg360\Reg360.mds" /run /project:Reg360 /test:"Smoke Tests|SmokeTest01TransgasE57import" /ErrorLog:C:\Reg360_smoke_tests\Export_Logs\SmokeTestsErrorLog /exit /SilentMode /ExportLog:C:\Reg360_smoke_tests\Export_Logs\SmokeTests_log.html /ExportSummary:C:\Reg360_smoke_tests\Export_Logs\SmokeTestsSummary /Timeout:3600

       

      Regards,

      Sameer

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi Sameer,

         

        > When I run the batch file, it launches TestComplete and then nothing happens; it does not run the tests.

        Yes, indeed, it looks like everything after /wait must be one command. And this command will be parsed later by separate copy of command processor.

        To get the above, your command line must be additionally quoted with proper number of quotes to met parsing rules. Try to surround the command in the batch file with additional quotes and check command processor's output to set quotes properly.

        You may try to start with the line like this:

        start /wait """C:\Program Files (x86)\SmartBear\TestExecute 12\Bin\TestExecute.exe" "C:\svn\TestComplete\DataPrepNew\DPSmokeTest\Reg360\Reg360.mds" /run /project:Reg360 /test:"Smoke Tests|Clean up" /ErrorLog:C:\Reg360_smoke_tests\Export_Logs\SmokeTestsErrorLog /exit /SilentMode /ExportLog:C:\Reg360_smoke_tests\Export_Logs\SmokeTests_log.html /ExportSummary:C:\Reg360_smoke_tests\Export_Logs\SmokeTestsSummary /Timeout:3600""