Hi,
We have scheduled our code to get executed daily at particular time.
The scheduled task daily executes the script i.e., at given it is double clicking the exe file.
The problem is the test data will be taken from database and our client want the scheduled task to execute only particular set of test cases and that too without updating the database.
Is it possible to know whether the script got initiated due to scheduled task. If so I can keep a if conditions and if yes it takes data from excel and if not it takes data from database.
Thanks
Abhigna
How to know script is getting executed byscheduled task
-
- Posts: 49
- Joined: Thu Feb 03, 2011 3:15 pm
- artur_gadomski
- Posts: 207
- Joined: Mon Jul 19, 2010 6:55 am
- Location: Copenhagen, Denmark
- Contact:
Re: How to know script is getting executed byscheduled task
I don't know if there is a way to tell if script is executed from scheduler, but you could add a command line parameter say '-database' to you test so that when present will make data come from database. Then you add this parameter into a scheduled run and you can still run the tests without parameters taking data from excel.
-
- Posts: 49
- Joined: Thu Feb 03, 2011 3:15 pm
Re: How to know script is getting executed byscheduled task
Hi Arthur,
Thanks for response.
I want scheduler to take data from excel only and manual execution will take data from database and how can we add only a single parameter to scheduled task.
Can be more specific on your reply "Then you add this parameter into a scheduled run and you can still run the tests without parameters taking data from excel."
Thanks
Abhigna
Thanks for response.
I want scheduler to take data from excel only and manual execution will take data from database and how can we add only a single parameter to scheduled task.
Can be more specific on your reply "Then you add this parameter into a scheduled run and you can still run the tests without parameters taking data from excel."
Thanks
Abhigna
- artur_gadomski
- Posts: 207
- Joined: Mon Jul 19, 2010 6:55 am
- Location: Copenhagen, Denmark
- Contact:
Re: How to know script is getting executed byscheduled task
You can write a code that checks the parameters like so:
Program: c:\Mytest.exe
Add arguments (optional): -excel
When you run it manually you just say MyTest.exe without any command line arguments (making it default way to run your tests).
static void Main(string[] args) { bool takeParametersFromExcel = false; foreach (string parameter in args) { if (parameter.Equals("-excel")) { takeParametersFromExcel = true; } } if (takeParametersFromExcel) { // Code taking parameters from excel } else { // Code taking parameters from database } }Then when you're scheduling a task you have an option to specify parameters (On Edit Action dialog -> Add arguments (optional)). So you just say:
Program: c:\Mytest.exe
Add arguments (optional): -excel
When you run it manually you just say MyTest.exe without any command line arguments (making it default way to run your tests).
-
- Posts: 49
- Joined: Thu Feb 03, 2011 3:15 pm
Re: How to know script is getting executed byscheduled task
Hi Artur,
Thanks for the solution.
It really helped me out in solving the issue. The code works fine now
Thanks
Abhigna
Thanks for the solution.
It really helped me out in solving the issue. The code works fine now
Thanks
Abhigna