Possibility to schedule test execution?

Hello,

I would like to know if it’s possible to schedule one (or several) tests execution with RF ?
For example, I would like to launch a suite test every day at 20 a clock.
I don’t find the way to do it…

Thanks !

Looks like your target isn’t achieved on robotframework layer, its CI or cron_job the things that you actually need

Hi John,

This shell script works for me on MacOS, and should work on linux, you would need to write something similar for windows.

This is my file “hourly.zsh”

cd /path/to/robot/files

n=1
while [ $n -gt 0 ]
do
	robot -i $(date "+AEST%H00") -l $(date "+AEST%H00_log.html") -r None -o $(date "+AEST%H00_output.xml") jobs.robot
done

the last test in jobs.robot, it’s job is to calculate the number of seconds remaining after all the previous tests have run and wait before exiting, then the loop repeats again on the next hour:

Finish The Hour
	[Tags]  	AEST1000	AEST1100	AEST1200	AEST1300	AEST1400	AEST1500	AEST1600	AEST1700	AEST1800	AEST1900	AEST2000	AEST2100	AEST2200	AEST2300	AEST0000	AEST0100	AEST0200	AEST0300	AEST0400	AEST0500	AEST0600	AEST0700	AEST0800	AEST0900
	${mins}= 	Evaluate    datetime.datetime.utcnow().strftime("%M") 	datetime
	IF 	'${mins}[0]' == '0'
		${mins}=	Set Variable    ${mins}[1]
	END
	${minr}= 	Evaluate    60 - ${mins}
	${secs}= 	Evaluate    (${minr}+1)*60
	Sleep    ${secs}

The other tests I want to run I just tag them with the hours I want them to run, some only have 1 hour tag e.g. AEST2000, some have many, AEST is my local timezone.

it was a quick and dirty solution, but it has worked reliably for months, and as they say nothing is more permanent than a temporary solution.

Hope that’s useful,

Dave.

Well, you don’t say what is your Operating System.

All of them have scheduling tools. For example on Windows I tried an old comand at and got:

C:\>at
The AT command has been deprecated. Please use schtasks.exe instead.

Usually I like to have a Jenkins server for any scheduling tasks. You can “easily” configure Jenkins on your local machine, because it is just a .JAR file. You can also use Docker.

Hello,
Thanks for all your answers !
My OS is Windows and I never use neither Jenkins nor Docker. I think it should learn to use one of them to reach my goal lol …

Jenkins is just one of the many of CI products and in many cases any CI product is sufficient for this types needs. I would choose the CI which your team is already using, in that way you will get support and help from your team out of the box. Also it provides easier integration for your team and less work for you, because you don’t have to maintain it.

But if you are just learning or your team doesn’t have a CI, then Jenkins is good place to start.

2 Likes