Forum Discussion

tkvaale's avatar
tkvaale
Occasional Visitor
8 years ago

How do I select multiple projects to run using TestComplete command line options or COM integration?

I have a test suite with multiple projects (each project may run for over an hour) and I want to select a subset of the projects to lower the total time and get more targeted testing. How can I achieve this?

 

Example:

I have the following projects: ConfigProject, Project1, Project2, Project3

On one specific software build I want to trigger testing of ConfigProject and Project2 (based on the changes since the previous build)

 

This need to be done automatically. The command line options only supports one project as far as I can see?

 

 

Any hints how to do this?

 

Thanks!

2 Replies

  • cunderw's avatar
    cunderw
    Community Hero

    Not sure if this will help exactly with how you want to run your tests, but the way we do it is all of our projects are stand-alone (ie. not tied to a single project suite as we have several hundred of them) and we store a list of project paths in a text file.

     

    We then use the following powershell script to automatically grab and run the next test on the list. This even works for distributing the load if you have the test list stored on a network share. Each running computer will just wait until the file is unlocked and grab whatever test is next on the list.

     

    Here's the code for the powershell script we use:

     

    function Get-LockedFile($FN, $FileMode,$FileAccess) {
        #Opens a file in locked mode and returns a file handle.  If the file is locked it waits until it becomes available.    
        $FileHandle = $null
        while ($FileHandle -eq $Null) {
            try {
                $FileHandle = [System.io.File]::Open($FN, $FileMode, $FileAccess, 'None')
            }
            Catch {
               Start-Sleep -Milliseconds 500 
            }
        }
        $FileHandle
    }
    
    function GetNextTest($app) {
        $FileName = "<PathToTestList>"
        $File = Get-LockedFile $FileName "Open" "ReadWrite"
        $Reader = New-Object System.IO.StreamReader($File)
        $NextTest = $Reader.ReadLine()
        if ($NextTest -eq "") {$NextTest = "EOT"}
        $RestOfFile = $Reader.ReadToEnd()
        $File.SetLength(0)
        $Writer = New-Object System.IO.StreamWriter($File)
        $Writer.WriteLIne($RestOfFile)
        $Writer.Flush()
        $File.Close()
        $NextTest
    }
    
    function LogTestCase($TC) {
        $Date = Get-Date -Format "yyyyMMdd"
        $File = Get-LockedFile "<pathToRunLog>" 'Append' "Write"
        $Writer = New-Object System.IO.StreamWriter($File)
        $TS = Get-Date
        $LogText = "$TS`t$env:computername`t$TC"
        $Writer.WriteLIne($LogText)
        $Writer.Flush()
        $File.Close()
    }
    
    function closeTestExecute() {
    	$testExecute = Get-Process TestExecute -ErrorAction SilentlyContinue
    	if ($testExecute) {
    		# try gracefully first
    		$testExecute.CloseMainWindow()
    		# kill after five seconds
    		Sleep 5
    		if (!$testExecute.HasExited) {
    			$testExecute | Stop-Process -Force
    		}
    	}
    	Remove-Variable testExecute
    }
    
    function run() {
        while ($NextTest -ne "EOT") {        
    		closeTestExecute
            $NextTest = GetNextTest($app)
            LogTestCase $NextTest
            $arg1 = "/r"
            $arg2 = "/SilentMode"
            $arg3 = "/e"
            $arg4 = "/DoNotShowLog"
            $AllArgs = @($NextTest, $arg1, $arg2, $arg3, $arg4)
            & "C:\Program Files (x86)\SmartBear\TestExecute 12\Bin\TestExecute.exe" $AllArgs | Out-Null
    	    
        }
    }
    
    run
  • m_essaid's avatar
    m_essaid
    Valued Contributor

    Hi,

    You should prepare your sets of projects by using one ProjectSuite per set.

    Then, choose the right ProjectSuite to launch.