Exposing Bitmaps 3

I have been watching Rails Bates RailsCasts for many years, and I am also a client of the site payment part. I learned BDD from watching cucumber episodes in the past.

Now I learned about TestUnit, RSpec, Capybara and MiniTest. I'm starting to get confused about something.

What is the difference between these 4 elements? I know, obviously, that Cucumber performs simple text functions, and I assume that this can be considered integration testing.

But now I also see that the latest versions of Cucumber require MiniTest? Is Cucumber just a DSL that sits on top of a testing platform?

I also know that RSpec has its own syntactic sugar for executing statements to โ€œdescribeโ€ blocks. And it looks like MiniTest also supports this syntax.

I know that Capybara is used to view the contents of the webpage that is being created, I think.

Here is my question:

If I create a new Rails 3.2 application, what combination of these testing programs should I use? What will be especially useful is a list that explains how these gems and related processes complement each other, if applicable, for example:

Cucumber is a DSL for driving BDD Cucumber is for integration tests and is based on creating user stories that are customer-readable It implements its tests behind the scenes via MiniTest MiniTest is a new testing framework that comes with Ruby 1.9 and is very fast. MiniTest is also used for unit testing, such as testing controllers and models It does not yet have as many features as RSpec Cucumber also uses Capybara to access DOM elements from a javascript-enabled browser simulator such as Selenium When you test in Rails, you have the ability to do the following kinds of tests: controllers, views, models, and integration (MVC together) Some people just do integration and model testing, because they feel that integration testing handles enough of the controller and view testing itself, and anything too complex can simply be moved up to the model 

Thank you so much for any help you can offer to clear these ideas for me.

+6
source share
1 answer

Ok let me try to explain based on my own experience

Cucumber is an ATDD (or BDD) tool that allows you to write tests in a business-oriented domain language. This primary use is a conversation tool with product owners. Instead of writing detailed requirements, you express these requirements as examples of the system under test. Each cucumber test, in fact, becomes a business requirement that must be satisfied.

The Cucumber tool itself translates these simple text instructions into a small module so you can execute ruby โ€‹โ€‹code. Which Ruby library you use inside the step definitions is completely dependent on the project you are working on.

The safest way to describe Cucumber is that it is a test framework with an emphasis on communication between IT and business partners, which is why it is becoming so popular.

Rspec and Minitest are other structures with other strengths, but do not have this coefficient of readability of the business, since they are mostly code and not so readable for non-technical people. This is not necessarily a bad thing, especially if your product owner has a bit more hands.

How does this relate to something like Capybara? Capybara is an integration test automation library that runs a mute browser on the Rack :: Test platform for very fast tests and has a well-read DSL. The only drawback is that Rack :: Test does not support javascript, so it provides the ability to change Selenium if you are doing a javascript test. Rspec and Cucumber have mechanisms to trigger this failure.

There are many other Ruby automation libraries. For example, if you test against a web application without rails, your cucumber scripts can be defined using Watir-Webdriver, which will control a full web browser, such as Capybara, in Javascript mode. The main difference is that WW has a much more robust set of selectors than Capybara, so itโ€™s a bit easier to write, especially if your code is not super clean (Capybara only supports selection by ID, Value and Text, whereas WW supports almost all whatever)

Most likely, you will want to use RSpec or Minitest to test your device) or the default Test :: Unit) and Cucumber to test integration, if you have an interested product owner or need a common language for test cases. If you do not, you can write your integration tests as examples of Rspec or the minimum equivalent without losing a lot.

+8
source

Source: https://habr.com/ru/post/915687/


All Articles