Announcing cucumber-electron
cucumber.io
cucumber.io
What is cucumber? What is Electron?
For example: "cucumber-electron is a Javascript module (available via npm) that combines cucumber, a framework for writing Web page tests in plain language, with Electron, a framework for building desktop apps using Web technologies. ..."
You can also get this behavior (basically single thread of execution) with cucumber-rails and Selenium (or probably any driver other than Selenium, for that matter). I'm not saying the application code is literally run in the same thread or process as the test executor, but in effect they do. Your Ruby process is in charge of setting up the HTTP server, as well as driving whatever driver (Selenium, Phantom, ...) you're using for Cucumber.
So serendipitously, with (MRI) Ruby being a single-threaded beast, you do still get that behavior and quality of being able to catch errors that pop up on either side, making it much easier to debug misbehaving server or tests.
Does this project require your system-under-test to be a pure Node.Js application to work with it? (I am not sure if I had heard of electron, but it looks to be the case.) Is there any possibility of porting this to be a driver for test systems that use Cucumber for systems built in other languages?
You could certainly use electron as a driver for tests written in other tech, but there is no capybara electron driver that I'm aware of. Using cucumber-electron means you write your step definitions (automation code) in JavaScript.
(I'm the author of cucumber-electron)
I've gotten used to having my rails application (server) running in the same thread as my cucumber (client-side) steps, thanks to cucumber-rails. So I could see why this would be especially useful for testing node.js applications, with the same advantages. (A fault detected anywhere on either side of the test execution, client or server, can be escalated and reported to stop the entire test, delivering a really good, clear idea of where to look in the code for the violator!)
This looks like a really neat project.
Only downside is you have to make it run with xvfb on the CI server, but that's pretty easy to set up in your config file usually.
https://chromium.googlesource.com/chromium/src/+/lkgr/headle...
(note: I am developing a python wrapper for controlling it: https://github.com/fake-name/ChromeController )
I've been meaning to see about wrapping the C++ api as a python module, but not had time.
Involve a QA person and relevant developers.
Catch the changes early, ask for more examples of the feature or goal, "have you thought about ...", "What happens in this case...?".
You will get better quality features with less rework, because you are writing the thing the PO actually wants and cover off edge cases before they crop up in testing.
The number one advantage is that using Cucumber produces human-readable documentation that is also executable, and through the magic of CI is prevented from becoming stale.
I use Cucumber with Rails, and I've actually heard a lot of really good arguments not to use Cucumber. The one thing these all seem to have in common is, they almost universally do NOT completely rebuke TDD at-large. Nobody (competent) is suggesting you should develop by the seat of your pants. They have issues with Gherkin or with Cucumber's implementation specifically, but if your team had success with Cucumber, you would not give it up without planning to have a replacement.
You may choose to eschew Gherkin style entirely, and you can certainly accomplish much the same thing using feature testing in modern RSpec and scenarios. This may be easier to refactor for you, but for me a well-organized vocabulary of step definitions makes it so easy to copy a scenario, reorganize the steps, and add some new things to create a new feature, adding almost no new test code.
There is also Spinach, which rips out all of Cucumber's regex silliness and declines to enforce a global vocabulary, instead encouraging modular design of scenarios and step definitions (since you might want to say the same thing in two different places and mean two different things.)
There is also Turnip, which integrates Gherkin into RSpec and also has many of the same advantages of Spinach, but includes other options (cleaner options) besides the Regex method for building parameterized step definitions. I think this one is my favorite, but my small project still uses Cucumber proper.
In the beginning of our project, it was very helpful that my PM was writing out requirements in Cucumber style. It meant that while someone (not a coder, but not an inexperienced PM either) had gone to the trouble to specify requirements with rigor, I could focus on coding, just jump in and start writing features, with a clear target of limited scope, that I could easily follow to avoid straying off into the weeds.
Before long my PM got busy with other projects and I took over writing the cucumber stories. Not just me, but the other dev too -- and that was just as well. I often found myself rewriting PM's scenarios anyway, to make them easier to map directly to step definitions, more clear in a context-free sense, or generally less ambiguously specified. These enhancements also made them less human-friendly.
Both approaches to writing Cucumber stories definitely have merit. The one thing you need to have is a strong set of test scenarios (however you've implemented them) with good total coverage of the features and the requirements, so that new or changed requirements can be evaluated in the context of the whole program: what features are broken by your change?
Two things I have found are also critical when using ATDD: your whole team (at least all of the devs) need to be able to run the tests, and (maybe even more important) you need to have a CI solution in place so that no individual needs to be responsible for running all of the tests after each change when your suite gets too heavy for a pre-commit hook. A regression suite is like a pager: when nobody is on-call then everybody is on-call.
Business rules change far less often than implementations, so the feature files shouldn't be tied to the implementation - that tying together can happen in the ruby code that implement the steps. You can refactor that code easily but the feature is denoting the business rule.
If you're using Cucumber (and not Spinach or Turnip) you need every (mechanically) different step to be (verbally) unique.
So they need to be descriptive enough to distinguish them from something not quite the same. They don't necessarily need to be descriptive enough to mechanically identify every button and selector used in English language, but they should not be so ambiguous that you could choose a different way and reach a different result.
The coolest thing I found is the ability to compose step definitions. So in my customer-level Gherkin, let's say I have some two-man workflow built around activities managing employee users, I can ultimately say:
"When I disable a user"
and I can implement this as
When(/^I disable a user$/) do
step "I select the user \"example user\""
step "I enter a termination date of today"
step "I select a termination reason of \"fired\""
step "Review Form is clicked"
step "Submit is clicked"
step "I log in as HR"
step "I pull up the submitted activity"
step "Complete is clicked"
step "I log in as Payroll"
step "I pull up the submitted activity"
step "Complete is clicked"
end
and I still haven't written a touch of Capybara or Ruby, but I've decoupled the business rule from the mechanical process.This is the greatest power feature of Cucumber, in my opinion.
They enable you to build the right thing - the thing that helps the users or meets the business goals.
Have a look for BDD, Behaviour Driven Development.
The main thing is to have the conversations. The automated tests are a lovely side effect!
http://www.popsci.com/science/article/2013-04/fyi-how-does-d...