Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cucumber/Capybara vs Selenium? [closed]

The other day I was showing one of the testers at my company some tests I had written in cucumber (2 features, 5 scenarios). Then he asked me question that I could not answer:

How is this better than selenium or any other functionality test recording tool?

I understand that cucumber is a different technology and it's placed at a different level of testing, but I can't understand why I should bother to write and maintain Cucumber/Capybara tests.

Can someone give me a reasonable explanation for using Cucumber/Capybara instead of just Selenium?

like image 259
treaz Avatar asked Jul 05 '12 17:07

treaz


People also ask

How is cucumber different from Selenium?

Selenium vs Cucumber: DifferencesSelenium is a test automation framework whereas Cucumber is a behavioural testing tool. Selenium is written in programming languages like Java, . Net, etc. whereas Cucumber is written both in programming language as well as plain text.

What is cucumber capybara?

cucumber is a BDD tool that expresses testing scenarios in a business-readable, domain-specific language. capybara is an automated testing tool (often used) for ROR applications.

What is Capybara Selenium?

Selenium. Selenium-webdriver, which is mostly used in web-based automation frameworks, is supported by Capybara. Unlike Capybara's default driver, it supports JavaScript, can access HTTP resources outside of application and can also be set up for testing in headless mode which is especially useful for CI scenarios.

What is Capybara Ruby?

Capybara is a library written in the Ruby programming language which makes it easy to simulate how a user interacts with your application. Capybara can talk with many different drivers which execute your tests through the same clean and simple interface.


1 Answers

This question is borderline asking for an opinion. Your question actually reads to me, "What tool is right for me?" I say this because you don't give a reason for why you chose Cucumber and Capybara. I believe to answer that tester's question, you need to answer a couple more questions first:

1.) What stage in the process are you going to be writing these tests?

Cucumber may not be the right choice for unit tests, depending on the language you're using. But it can be used for any level of testing, from unit to integration to end-user.

2.) Who is going to maintaining your tests? You? Other developers? Testers? Business Analysts? Project Managers?

Automated tests must be maintained, and knowing who will be doing that can help you decide on a tool - as some will be too technical for certain users.

3.) Who is going to be defining new tests?

Cucumber is meant to be used collaboratively between development, QA and business owners. It is the perfect tool for leveraging everyone's knowledge into the automated testing process. It requires the development of an ubiquitous language to be effect however. You can read up on that on James Shore's Art of Agile page.

Once you've answered these questions, you're ready to address the tester's question.

However, there are a couple of points to keep in mind when comparing recording tools (such as Selenium IDE, HP Quick Test Pro, IBM Rational Functional Tester) vs. development tools (nUnit, jUnit, RSpec, Selenium webdriver, Capybara) is that they are targeted towards different audiences. They also have different plusses and minuses.

Recording tools are easy for anyone to use, but the scripts they create are fragile. They break easily and require more maintenance. They are great for one-off automated testing, where you need to get it done quickly and have non-technical manpower.

Development tools have a larger learning curve and require programming (or at the least scripting) experience. The scripts are generally more robust, but require more technical knowledge to maintain. They are a good solution when you want repeatability and plan to use tests for a long time.

I strongly suggest you read The Cucumber Book. It will really help you decide if Cucumber is the right choice for you.

like image 171
Doug Noel Avatar answered Oct 01 '22 15:10

Doug Noel