| || |
Automation with Selenium
Need inputs and advise in automating Ruby on Rails Projects with Selenium..
Need to start from the scratch since currently we have only Manual /Functional testing in place..
It's hard to advise without knowing where your grounding is, and what you're looking for.
Originally Posted by Shimithlal
I've only worked with Rails/Selenium on a personal project briefly. So I can only tell you what works for me. (This was a side project which I was the sole developer/tester, that's why I had testing tightly integrated.)
Here are the frameworks I used:
* On the top level, I used Cucumber for managing the tests. This allows me to create a Story like structure for viewing the test results that is more readable to business folks.
- For configuration management, I used what's called 'TheWorld', which is a global object in Cucumber. I have a simple init script that dumps a bunch of settings from a config file onto the world.
* Just below the surface, I have a package called "pages", which I use to organize my page objects. Page objects I organize by their route keys to make easier for developers to correlate to their corresponding routes.
* For creating test data and DB entries, I used Factory Girl. This a great way for managing DB dependencies when creating test data, and also tear them down quickly.
* When in dev context, I used PhantomJS as the webdriver, I have 'Guard' monitoring change src files, which automatically detects file changes and runs the corresponding tests.
* When in integration and test context, I have them using Selenium Grid so I can test on real browsers.
I don't know if you also want to know about JS unit testing as well. Karma with Selenium Grid is a good way to implement the JS unit testing on a rails project.
The idea of this work flow is to use TDD methodologies. My work flow dev/qa as follows..
1. Planning - I write the story I want to work on next in Gherkin format that Cucumber uses. "As a User... I want to do .... So that...", along with it's acceptance criteria "Given... When... Then..." These are added to Cucumber and will turn into failing tests.
2. For each Given, When, Then. I would then implement the page object scaffolding while I implemented the functionality.
3. After the initial dev work is complete, the Cucumber will now be passing.
4. I'll then go write RSpec unit tests and JS unittests (back then I was using Qunit/testswarm, but now a days I recommend Karma)
5. Go back and refactor the implementation code to optimize it. Because I have working acceptance tests and unittests, guard will tell me the moment I break something, which makes refactoring much safer.
6. After refactoring, I switch to integration testing mode, then rerun all the tests on real browsers.
7. Deploy and have a beer.
Last edited by dlai; 10-03-2013 at 10:57 AM.