Currently I am using Cucumber Options with plugin to invoke Custom Report Class implements Reporter. How to do it in newer Cucumber 4 version. Mainly to get Test Results to build own custom reports.
You can implement the Formatter interface - https://github.com/cucumber/cucumber-jvm/blob/master/core/src/main/java/cucumber/api/formatter/Formatter.java.
Though this is planned for removal. - https://github.com/cucumber/cucumber-jvm/issues/1401
Better off using the Plugin - https://github.com/cucumber/cucumber-jvm/blob/master/core/src/main/java/cucumber/api/Plugin.java plus EventListener - https://github.com/cucumber/cucumber-jvm/blob/master/core/src/main/java/cucumber/api/event/EventListener.java
Also look at ConcurrentEventListener https://github.com/cucumber/cucumber-jvm/blob/master/core/src/main/java/cucumber/api/event/ConcurrentEventListener.java if u plan to use parallel running - https://github.com/cucumber/cucumber-jvm/pull/1357
I'm trying to do a DRY cucumber feature and I'm facing a problem of converting a string into an ActiveRecord model name
Given /^the following "(.+)" exist:/ do |mod, table|
table.hashes.each do |t|
mod.create!(t)
end
assert mod.all.count == table.hashes.size
end
that gives
undefined method `create!' for "Balloon":String (NoMethodError)
More elegant solution might be to use a factory, but I'm wondering whether it is possible to use the above approach?
You could look into constantize which turns a String into a constant. Try:
"Balloon".constantize.create!(t)
BUT: Using your app code (models in particular) in a Cucumber step is code smell. Your integration tests shouldn't rely on the code under test at all—think of your app as a black box when you implement Cucumber steps. (Also think of a refactoring of your models that require you to go back and change your Cucumber steps—that's your first clue that you're on the wrong track!)
What you could do to improve this is create the models using an API (if your app implements one).
That way, you only rely on those parts of your app that are public-facing.
On another note: Your Given shouldn't have an assertion, it's more like a before hook in RSpec, setting up a condition for a later assertion...
I'm trying to move a project over to using Entity Framework, but to make it more fun, the project is in C++/CLR.
I've got a query
ObjectQuery<myData::Facility^>^ facQ = myContext->FacilitySet;
and I want to do this
int n = facQ.Count()
But I can't because c++ doesn't recognise extension methods using C# syntax. facQ->Count() doesn't work.
Using C# extension methods from managed C++/CLI shows the answer for user-defined extensions; but in this case, the extension is part of the .NET framework http://msdn.microsoft.com/en-us/library/bb349034%28v=vs.90%29.aspx.
Any ideas?
(I'm using visual studio 2008, and .NET 3.5).
System::Data::Objects::ObjectQuery implements IEnumerable<T>. The Count() method you see in C# is from the System::Linq::Enumerable class.
using namespace System::Linq;
int n = Enumerable::Count(facQ);
Also see this answer, which shows a couple examples of calling other extension methods in that class.
What is used for BDD and TDD with node.js?
I'm used to use Cucumber + RSpec. What's a good combo for node.js?
thanks
Update
Mocha gets my vote now!
You could have a look at the testing modules section from the node.js modules page. For example Vows is a pretty popular BDD framework.
Vows is a behavior driven development framework for Node.js.
Check out mocha - (github)
Also mocha-cakes, my attempt for Cucumber syntax on mocha.
If you are used to rspec, Jasmine is pretty nice. I've not used it on Node.js, but I have used it for testing a backbone app. It's syntax is very similar to rspec. Taken from the site above:
describe("Jasmine", function() {
it("makes testing JavaScript awesome!", function() {
expect(yourCode).toBeLotsBetter();
});
});
It's listed in the link provided by Alfred above, but since folks listed Vows as an example, I figured I'd give Jasmine a bump, especially since it's syntactically similar to rspec ;)
There is the 'Vows' project for BDD on Node http://vowsjs.org, looks pretty nice. It's a bit different from RSpec/Cucumber, but it's pretty fun
Maybe a little later, but what you're looking for is Kyuri: https://github.com/nodejitsu/kyuri
"kyuri is a node.js Cucumber implementation with a few extra asynchronous keywords. it supports 160+ languages and exports to VowsJS stubs"
Also, nodejitsu seems to have built a web app for managing a project Kyuri feature specs in a collaborative way, it's named "prenup", I would give it a look.
You could also try yadda. It plugs into other test libraries including mocha, jasmine, casper & webdriver, but also lets you write proper feature files instead of merely annotating you tests in situ. A typical test might look like...
var Yadda = require('yadda');
Yadda.plugins.mocha();
feature('./features/bottles.feature', function(feature) {
var library = require('./bottles-library');
var yadda = new Yadda.Yadda(library);
scenarios(feature.scenarios, function(scenario, done) {
yadda.yadda(scenario.steps, done);
});
});
And the feature file...
Feature: Mocha Asynchronous Example
Scenario: A bottle falls from the wall
Given 100 green bottles are standing on the wall
when 1 green bottle accidentally falls
then there are 99 green bottles standing on the wall
And output...
Mocha Asynchronous Example
✓ A bottle falls from the wall
1 passing (12ms)
Check out Buster.JS. Created by Christian Johansen, who literally wrote the book on javascript testing.
Buster supports both TDD and BDD. It does browser testing with browser automation (think JsTestDriver), QUnit style static HTML page testing, testing in headless browsers (PhantomJS, jsdom), and more.
Package a
(bdd and mocking)
https://npmjs.org/package/a
Very compact syntax, context separated from acts, chainable acts.
Easy Cmd line runner that searches recursively.
Unit tests: Mocha is great for unit tests.
BDD tests If you want a BDD test framework for Node.js then I'd recommend the Cucumber package.
I was going through the same concern last month .
For BDD :
Though Mocha itself provides BDD style by their describe and it statements.
For styles like cucumber , you can try :
mocha-cakes
mocha-gherkin
cucumber.js
kyuri
mocha-cucumber
They all have their own styles. I am sorry I can not provide working snippets now , let me know #Donald which one you select. Would like to know your insight.
I too was looking for a good Gherkin implementation, found mocha-cakes/mocha-cakes-2 which were nice but not very full featured. So I build my own with mocha as the base, which has parity with the gherkin language including Scenario Outlines. It also makes it easy to reference the data in your test. Its different to cucumber.js as its all inline not separate files. You can find the project here:
livedoc-mocha
I am trying to use authlogic's test helpers in Cucumber, calling activate_authlogic.
Our application_controller has a current_user_session method.
When we drop into the debugger mid-story, controller returns a Authlogic::TestCase::MockController.
But when we call controller.current_user_session.
The error occurred while evaluating nil.current_user_session.
How does this mock suddenly become a nil?
And does this mock controller know about our application controllers' code?
I don't know authlogic (and if this answer is helpful at all), but where does that mock object come from in the first place? You shouldn't be using any mocks in you cucumber stories. Cucumber is like an integration test, testing the complete Rails Stack.
I use it, to make sure, that my view, controller and model specs haven't diverged from each other.