How to ramdomly select test cases among the test suite to run daily?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

How to ramdomly select test cases among the test suite to run daily?

#1 Post by goodywp » 02 Oct 2024 10:09

Hi all,
I have a task to run robot framework test cases automatically.
I set up everything and the only thing I faced is to select about 10 test cases to be run each day, and within a week, the whole test suites are ideally to be run at least once., let's say about 90%, not necessary this number...
Here is the condition: usually we set up a tag under this test case name so that it can be picked up to be run in the execution as below:
Sample as this below:

Code: Select all

Test 01-Sale and Void Sale VISA Contact
    [Tags]    BVTN
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 02-Sale MASTERCARD
    [Tags]    BVTN
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT
Now there are 50 test cases in total, I do not want to list them all here

Currently I manually put tag under 10 test cases within these 50 test cases. So I am looking for a solution to automatically rotate these tags from one test case to another test case within a week, let say this way below:
Day1 (Mon) these 10 tages under below test cases Test 01, Test 02, Test 11, Test 12, Test 21, Test22, Test 31, Test 32, Test 41, Test 42 by insert tag under the test case name as showing in the above.
Day2 (Tue) these 10 tages under below test cases Test 03, Test 04, Test 13, Test 14, Test 23, Test24, Test 33, Test 34, Test 43, Test 44
Day3 (Wec) these 10 tages under below test cases Test 05, Test 06, Test 15, Test 16, Test 25, Test26, Test 35, Test 36, Test 45, Test 46
Day4 (Thu) these 10 tages under below test cases Test 07, Test 08, Test 17, Test 18, Test 27, Test28, Test 37, Test 38, Test 47, Test 48
Day5 (Fri) these 10 tages under below test cases Test 09, Test 10, Test 19, Test 20, Test 29, Test30, Test 39 Test 40, Test 49, Test 50

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: How to ramdomly select test cases among the test suite to run daily?

#2 Post by Aacini » 02 Oct 2024 12:44

Hmm... Although I completely understand what you need, there are several details that prevent me from writing any useful code. The most important point is: how do you know that a test case has already been run? Anyway, here there are a couple ideas:

Code: Select all

@echo off
setlocal EnableDelayedExpansion

set "base=1, 2, 11, 12, 21, 22, 31, 32, 41, 42"
set "i=0"
for %%d in (Mon Tue Wed Thu Fri) do set /A i+=1 & set "day[!i!]=%%d"

for /L %%d in (1,1,5) do (
   set "tests="
   for %%t in (%base%) do (
      set /A "test=%%t+(%%d-1)*2+100"
      set "tests=!tests!Test !test:~1!, "
   )
   echo Day%%d (!day[%%d]!^): !tests!
)
Output:

Code: Select all

Day1 (Mon): Test 01, Test 02, Test 11, Test 12, Test 21, Test 22, Test 31, Test 32, Test 41, Test 42, 
Day2 (Tue): Test 03, Test 04, Test 13, Test 14, Test 23, Test 24, Test 33, Test 34, Test 43, Test 44, 
Day3 (Wed): Test 05, Test 06, Test 15, Test 16, Test 25, Test 26, Test 35, Test 36, Test 45, Test 46, 
Day4 (Thu): Test 07, Test 08, Test 17, Test 18, Test 27, Test 28, Test 37, Test 38, Test 47, Test 48, 
Day5 (Fri): Test 09, Test 10, Test 19, Test 20, Test 29, Test 30, Test 39, Test 40, Test 49, Test 50, 
How do you get the DayOfWeek from the date? Simple:

Code: Select all

for /F "tokens=1-3 delims=/" %%a in ("%date%") do (
   set /A "m=%%a, d=%%b, y=%%c, a=(m-14)/12, DOW=((1461*(y+4800+a))/4+(367*(m-2-12*a))/12-(3*((y+4900+a)/100))/4+d-32074)%%7"
)
Reference: Julian Day Number

Antonio

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: How to ramdomly select test cases among the test suite to run daily?

#3 Post by goodywp » 02 Oct 2024 13:32

Thanks Aacini!

My bad! I think that the output maybe confused you as example I showed above.
What my intention was to automatically the insert this line
[Tags] BVTN
into diffferent test case name lines in the Test_Suite file as more detailed example as below:
Let's take Monday as example. First we have a test suite file called Test_Suite.robot
In this file there are test cases as
  • Test 01-Sale and Void Sale VISA Contact
    [Tags] BVTN
    ${Invoice} Evaluate random.randint(1,999999)
    Transaction flow without Check SALE ${Invoice} ${Visa} 100 ${EMPTY} LANG
    Get Receipt and Log VISA SALE
    Start Void transaction ${Acquirer} ${Invoice}
    Check Transaction result

    Test 02-Sale MASTERCARD
    [Tags] BVTN
    ${Invoice} Evaluate random.randint(1,999999)
    Transaction flow SALE ${Invoice} ${MC_MasterCard} 100 4315 ${EMPTY} CREDIT

    ........................

    Test 41-Sale MASTERCARD
    [Tags] BVTN
    xxxxxxxxxxxx

    Test 42-Sale MASTERCARD
    [Tags] BVTN
    xxxxxxxxxxxx
So under these test cases name of Test 01, Test 02, Test 11, Test 12, Test 21, Test 22, Test 31, Test 32, Test 41, Test 42 in this Test_Suite file will be added one more line [Tags] BVTN as the above example


Then Tuesday all the test cases name as
  • Test 03-Sale and Void Sale VISA Contact
    [Tags] BVTN
    ${Invoice} Evaluate random.randint(1,999999)
    Transaction flow without Check SALE ${Invoice} ${Visa} 100 ${EMPTY} LANG
    Get Receipt and Log VISA SALE
    Start Void transaction ${Acquirer} ${Invoice}
    Check Transaction result

    Test 04-Sale MASTERCARD
    [Tags] BVTN
    ${Invoice} Evaluate random.randint(1,999999)
    Transaction flow SALE ${Invoice} ${MC_MasterCard} 100 4315 ${EMPTY} CREDIT

    ........................

    Test 43-Sale MASTERCARD
    [Tags] BVTN
    xxxxxxxxxxxx

    Test 44-Sale MASTERCARD
    [Tags] BVTN
    xxxxxxxxxxxx
Hopefully it is clear now

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: How to ramdomly select test cases among the test suite to run daily?

#4 Post by Aacini » 02 Oct 2024 20:07

Ok. What about this code?

Code: Select all

@echo off
setlocal EnableDelayedExpansion

rem Get today's DayOfWeek
for /F "tokens=1-3 delims=/" %%a in ("%date%") do (
   set /A "m=%%a, d=%%b, y=%%c, a=(m-14)/12, DOW=((1461*(y+4800+a))/4+(367*(m-2-12*a))/12-(3*((y+4900+a)/100))/4+d-32074)%%7"
)

rem Create a list with the desired tests for today
set "tests="
set /A t1=(t2=100+DOW*2)-1
for /L %%i in (1,1,5) do (
   set "tests=!tests! !t1:~1! !t2:~1!"
   set /A t1+=10, t2+=10
)

rem Process the file
for /F "tokens=1*" %%x in ("%tests%") do set "next=%%x" & set "tests=%%y"
(for /F "tokens=1,2* delims=:-" %%a in ('findstr /N "^" input.txt') do (
   if "%%c" neq "" (
      echo %%b-%%c
      if "%%b" == "Test !next!" (
         echo     [Tags]    BVTN 
         for /F "tokens=1*" %%x in ("!tests!") do set "next=%%x" & set "tests=%%y"
      )
   ) else (
      echo/%%b
   )
)) > output.txt
Input:

Code: Select all

Test 01-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 02-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 03-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 04-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 05-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 06-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 07-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 08-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 09-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 10-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 11-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 12-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 13-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 14-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 15-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 16-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 17-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 18-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 19-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 20-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 21-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 22-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 23-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 24-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 25-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 26-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 27-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 28-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 29-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 30-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 31-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 32-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 33-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 34-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 35-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 36-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 37-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 38-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 39-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 40-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 41-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 42-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 43-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 44-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 45-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 46-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 47-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 48-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 49-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 50-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT
Output:

Code: Select all

Test 01-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 02-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 03-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 04-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 05-Sale and Void Sale VISA Contact
    [Tags]    BVTN 
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 06-Sale MASTERCARD
    [Tags]    BVTN 
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 07-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 08-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 09-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 10-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 11-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 12-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 13-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 14-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 15-Sale and Void Sale VISA Contact
    [Tags]    BVTN 
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 16-Sale MASTERCARD
    [Tags]    BVTN 
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 17-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 18-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 19-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 20-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 21-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 22-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 23-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 24-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 25-Sale and Void Sale VISA Contact
    [Tags]    BVTN 
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 26-Sale MASTERCARD
    [Tags]    BVTN 
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 27-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 28-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 29-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 30-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 31-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 32-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 33-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 34-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 35-Sale and Void Sale VISA Contact
    [Tags]    BVTN 
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 36-Sale MASTERCARD
    [Tags]    BVTN 
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 37-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 38-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 39-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 40-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 41-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 42-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 43-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 44-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 45-Sale and Void Sale VISA Contact
    [Tags]    BVTN 
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 46-Sale MASTERCARD
    [Tags]    BVTN 
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 47-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 48-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT

Test 49-Sale and Void Sale VISA Contact
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow without Check    SALE    ${Invoice}    ${Visa}    100    ${EMPTY}    LANG
    Get Receipt and Log    VISA    SALE
    Start Void transaction    ${Acquirer}    ${Invoice}
    Check Transaction result
    
Test 50-Sale MASTERCARD
    ${Invoice}    Evaluate    random.randint(1,999999)
    Transaction flow    SALE    ${Invoice}    ${MC_MasterCard}    100    4315    ${EMPTY}    CREDIT
Antonio

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: How to ramdomly select test cases among the test suite to run daily?

#5 Post by goodywp » 03 Oct 2024 08:59

I gave a try just using the above code and input.txt
I got this Missing operand...no more details...

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: How to ramdomly select test cases among the test suite to run daily?

#6 Post by Aacini » 03 Oct 2024 09:41

Is MM/DD/YYYY your %DATE% format? If not, you need to adjust the m=%%a, d=%%b, values in the formula.

Just open a cmd.exe command prompt window (click on Start, type cmd and select the black cmd.exe window), do a CD to the right directory, remove the @echo off line and run the program. You will see on the screen the error message followed by the line(s) that caused it...

Antonio

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: How to ramdomly select test cases among the test suite to run daily?

#7 Post by goodywp » 03 Oct 2024 10:29

Terrific! After changed the DATE format for that PC and it works!
Thanks again Aacini!

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: How to ramdomly select test cases among the test suite to run daily?

#8 Post by goodywp » 03 Oct 2024 12:14

Hi Aacini,
just realized that there are some issue regarding some characters as this
From the attached two files, one input.txt and output.txt

You can see this code did the job but also did some extra job such as

orignal in input.txt = ----> in output.txt become !=
orignal in input.txt - ----> in output.txt become :


Can we just make this code only happen after this line as *** Test Cases *** in index.txt ?
It really just need do the insertation after this line *** Test Cases ***
Please see the original input file as original file was.
Attachments
output_sample.txt
(12.68 KiB) Downloaded 278 times
input_sample.txt
(12.47 KiB) Downloaded 577 times

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: How to ramdomly select test cases among the test suite to run daily?

#9 Post by goodywp » 03 Oct 2024 14:29

goodywp wrote:
03 Oct 2024 12:14
Hi Aacini,
just realized that there are some issue regarding some characters as this
From the attached two files, one input.txt and output.txt

You can see this code did the job but also did some extra job such as

if the orignal input.txt has this != ----> = will show up as in output.txt
if the original input.txt has this : ----> - will show up as in output.txt


Can we just make this code only happen after this line as *** Test_Cases *** in input.txt ?
It really just need do the insertation after this line *** Test_Cases ***
Please see the original input file as original file was.
I can use this piece code to find the line of *** Test_Cases ***

Code: Select all

FOR /F "delims=: tokens=1*" %%i in ('findstr /N /I "Test_Cases" "input.txt"') do ( set lnum=%%i)
echo "%lnum%"
But do not know how to jump to this line of the input.txt file and start the function of your code?

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: How to ramdomly select test cases among the test suite to run daily?

#10 Post by goodywp » 04 Oct 2024 09:48

I also tried to split this input file into two files using string Test_Cases or only Cases to separate the file.
But end up many in searching but none of it works for me so far. Any idea to do this job so that I can use the code to do the insertation.
Thanks

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: How to ramdomly select test cases among the test suite to run daily?

#11 Post by Aacini » 04 Oct 2024 16:46

goodywp,
I am afraid I don't follow you...
goodywp wrote:
03 Oct 2024 12:14
Hi Aacini,
just realized that there are some issue regarding some characters as this
From the attached two files, one input.txt and output.txt

You can see this code did the job but also did some extra job such as

orignal in input.txt = ----> in output.txt become !=
orignal in input.txt - ----> in output.txt become :
If you are saying that the equal character "=" is changed to "!=" and the dash "-" is changed to colon ":", then perhaps you have not noticed that there is not a single equal "=" character in the posted input_sample.txt file and that all the 50 dash "-" characters present in the input_sample.txt file have been successfully copied to the output_sample.txt file...
goodywp wrote:
03 Oct 2024 12:14
Can we just make this code only happen after this line as *** Test Cases *** in index.txt ?
It really just need do the insertation after this line *** Test Cases ***
Please see the original input file as original file was.

----------

I can use this piece code to find the line of *** Test_Cases ***

But do not know how to jump to this line of the input.txt file and start the function of your code?

----------

I also tried to split this input file into two files using string Test_Cases or only Cases to separate the file.
But end up many in searching but none of it works for me so far.
Would you be surprised if I told you that there is NOT a line with Test_Cases string in the input_sample.txt file? So I don't know what you are talking about in your last 3 replies...

It should be curious that when you "Replied with quote" to your own reply, you fixed your own errors: "Test_Cases" instead of "Test Cases" and "input.txt" instead of "index.txt". However, these "mistakes", and the fact that you are apparently talking about a data file that you have NOT published, only show how little interest you have in accurately describing your problem to the people who will help you to solve it, for free!

Before posting any new reply, I recommend that you carefully read the first topic of this site that you must have seen every time you come to this site, particularly these parts:
miskox wrote:
16 Jun 2024 11:39
The fastest way to get code that is robust and efficient is to clearly describe what you need to do and then let the programmers decide the best way to handle the job.

Batch files are often specific to your task because your text and data are often used to write code that is both simpler and more efficient.

It makes it easy for people if you provide accurate details. The script you are given is designed to work in your specific situation and they will often add extra code to handle aspects that you may not have thought of.

If you hide your details by using fake file information then nobody knows if you are using things like poison characters for batch scripts. In these situations the volunteers can't include appropriate code to handle your special situations because they aren't aware you need it.

By providing poor information about your task the code you are given stands a good chance of failing.

Batch code is often written by analysing the characters and the patterns in text that are being handled by the batch script. Wrong analysis, when all you have is wrong data, just leads to wrong batch code.

The layout of your text is also important when writing code so don't change the layout or length of these lines.

Please show respect to those people who give their free time to provide you with code by giving them accurate information about your task.

What happens in a thread when incorrect or poor details are supplied: is that the volunteers write a script based upon that information and the next post often comes from the question writer saying "It doesn't work!"

Often a very long series of posts begins where we try to ascertain what the problem is and how the code fails and then what the real details of the task are. The script has to be rewritten, and that just wastes the time of those volunteers who are giving you free code and it is terribly frustrating and unsatisfying for volunteers to have to re-write a script for the same task again.

Don't do this.
Antonio

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: How to ramdomly select test cases among the test suite to run daily?

#12 Post by goodywp » 07 Oct 2024 07:51

Thanks Antonio!
Yes it was my bad and did not attached the real sample of my input file. Just tried to make it simple and did not realize that something weird come up along with the real samples.
So when I tried to use your code to do the insertation on my real files not the simplified file at the beginning, I got some extra changes besides the insertation of BVTN.
So if you checked the below attached files you shall see the extra stuff after inserting....
The first file is Real_Input.txt
The second file is Real_Output.txt
You shall see besides the insertation also some characters impacted...
Attachments
Real_Output.txt
(25.36 KiB) Downloaded 1031 times
Real_Input.txt
(25.6 KiB) Downloaded 1034 times

Post Reply