Incrementing Project.Variables from command line test execute
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Incrementing Project.Variables from command line test execute
Hi,
I have the below test structure but the variable not getting value from the command line.
Variable page -> Temporary
I have a var called count which has 0 as default value
I have a command line in which I have added TestComplete.exe "C:\Work\My Projects\MySuite.pjs" /run /pv:count=%x%
here %x% = 0,1,2,.... (increments each time command line executes) depends on the test run 1,2,3,4....
I have a After Feature hook that stores:
var count = Project.Variables.count;
Log.Message(count);
The problem is that count is always 0.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can we see the full command/parameter that you are using please? I want to see how %x% is populated
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
setlocal enableextensions enabledelayedexpansion
set /a "x = 0"
set /a "timeout = 1"
:while1
echo top
if %x% leq 1 (
Call %loc6%\abc.bat
goto Other
:middle
set /a "i = x + 1"
echo x: %x%, timeout: %timeout%, i: %i%
%loc0%\testexecute.exe "%loc3%" /r /p:%project% /t:ProjectTestItem%i% /PrjVar:count=%x% /DoNotShowLog /timeout:%timeout%
echo %x%
if ERRORLEVEL 4 (goto timeout)
if ERRORLEVEL 3 (goto generalfail)
goto closesoftware
goto exitsoftware
:bottom
set /a "x = x + 1"
goto :while1
)
goto Exit
..........................................................
The count variable type is 'Integer' in the Variables page.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here's an example: TC Project
Batch file,
echo off
setlocal enableextensions enabledelayedexpansion
set /a x = 1
:loop
if %x% leq 5 (
echo x: %x%
"c:\Program Files (x86)\SmartBear\TestComplete 15\x64\Bin\TestComplete.exe" "c:\Sandbox\ALT\TestComplete\Number\Number.pjs" /run /exit /project:Number /prjvar:Var1=%x% /donotshowlog
set /a x = x + 1
goto :loop
)
:end
echo finished
It will loop 5 times, calling TC and passing the appropriate variable %x%
Try write something simple, and get it to work.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@rraghvani Thanks for your reply!
The %x% increments in my code with every run, don't know why it doesn't update the variable though.
Because, I am using test execute, will that also update the variable like you have done with test complete.exe?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it will update.
Note that parameter /exit
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tried everything, no luck! I'm totally stuck. Really need to get it working. I got test complete 14, is that something to worry about?
Also, the command line arguments depends too much on when the text execute exits/stops. When exactly I need to stop the test execute if I want to pass the project variable value? In my test, I exit the test execute in Error handler as well.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you were to call the command (amend for TestExecute) and pass the variable,
"c:\Program Files (x86)\SmartBear\TestComplete 15\x64\Bin\TestComplete.exe" "c:\Sandbox\ALT\TestComplete\Number\Number.pjs" /run /exit /project:Number /prjvar:Var1=100 /donotshowlog
Does it show the number you passed, in the log file?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
echo off
setlocal enableextensions enabledelayedexpansion
set /a x = 1
:loop
if %x% leq 5 (
echo x: %x%
start /wait "C:\Program Files (x86)\SmartBear\TestComplete 14\x64\Bin\TestComplete.exe" "C:\Users\test\Documents\TestComplete 14 Projects\ProjectSuiteTest\ProjectSuiteTest.pjs" /run /e /p:TestProjecttt /t:ProjectTestItem1 /prjvar:count=%x% /donotshowlog /ExportLog:"C:\Users\test\Documents\TestComplete 14 Projects\TestLog.mht"
set /a x = x + 1
goto :loop
)
:end
echo finished
I also tried your code, but still getting zero.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you create this project,
and call the command line,
"C:\Program Files (x86)\SmartBear\TestComplete 14\x64\Bin\TestComplete.exe" "C:\Users\test\Documents\TestComplete 14 Projects\Number\Number.pjs" /run /exit /project:Number /prjvar:Var1=100 /donotshowlog
To run the project in TestComplete please.
Then, open the project in TestComplete and look at the log file. What does the output show?
