Currently, I'm running all selenium scripts in my test suite (written by Selenium Ruby Webdriver) at one time by using rake gem in "Start Command Prompt with Ruby" terminal.
To do this I have to create a file with name "rakefile.rb" with below content and just call "rake" in my terminal: (I have known this knowledge based on the guide of a person in my previous posts).
task :default do
FileList['file*.rb'].each { |file| ruby file }
end
However, running will be terminated if there is one script got failure when executing.
Anybody please help guide me how to modify "rakefile.rb" so that if there is one script failed, then system will ignore it and continue to run the next script in my test suite ?
Also, could you please suggest me a way to write all results when running scripts to one output file ?, or the result of each script is put in each output file and a output file will display the list of scripts failed. Any help is appreciated. Thanks so much.
I run all my tests inside a unit framework. I use test-unit myself but you could also use rspec. This also gives you the ability to add assertions to your code and then have it be reported by the unit framework. If one test fails or errors you can move on to the next test.
a simplified version of my rakefile looks like this
and every test case looks like this
You could use a
begin
andrescue
to catch any failures in your test scripts.Something like
Which in your case would be something like
and as of writing to a file that would be something like
What that does is override $stdout to redirect the console output.