Reputation: 141
I have a question about Robot Framework test case naming conventions and running a test case with .bat-file on Windows-10 laptop. During my limited experience of working with Robot Framework I have been mostly using RIDE-editor and there has not been many problems when running with that.
When looking at test case naming conventions in a link below a good way seems to be to put
space between words. Very simple example being Open Browser
so there is a space between those
two words belonging to a test case name. Longer example would be Empty Username And Password
I personally like that kind of style with spaces.
However I noticed that if I try to run from .bat-file like this.
robot -t testcasename testsuitename.robot
@echo off
cd C:\Users\developer\Robot
robot -t Open Browser Demosuite.robot
Then command prompt just blinks shortly before disappearing and running test case like that does not work. When running with RIDE-editor there is no problem with running.
But if I rename test case like this.
@echo off
cd C:\Users\developer\Robot
robot -t Open_Browser Demosuite.robot
That works. So is this expected behaviour that it should not work with spaces when running from .bat?
Robot Framework-code:
Resource Resources/CommonResources.robot
*** Test Cases ***
Open Browser
Open Browser https://www.google.com Firefox
Upvotes: 1
Views: 2017
Reputation: 385970
The problem is related to how windows and other operating systems handle arguments on the command line. Windows knows nothing about robot and doesn't know anything about the -t
argument or what it expects. When it sees robot -t Open Browser Demosuite.robot
it sees the following:
* command name: robot
* argument 1: -t
* argument 2: Open
* argument 3: Browser
* argument 4: Demosuite.robot
Notice that "Open" and "Browser" are treated as two separate arguments.
Passing arguments with spaces, whether with robot or any other command line tool, requires that you use quotes. In your case you could do robot -t "Open Browser" Demosuite.robot
, or as you observed you can use an underscore in place of the space which robot (and likely only robot) will convert to spaces for you.
Upvotes: 3