What are the formatter parameters in behat.yml? - behat

The formatter section in this guide on configurations gives an example of formatter parameters, but doesn't explain them:
# behat.yml
default:
formatter:
name: pretty
parameters:
decorated: true
verbose: false
time: true
language: en
output_path: null
multiline_arguments: true
#...
There is no explanation for what verbose or decorated does, I have tried setting to true and false but it seemed to make no difference. Also I was wondering if there are any other parameters which aren't in that example.
Can anyone please explain what these parameters do?

A quote from the link you provided:
The parameters section defines additional parameters which will be provided into the formatter instance. As you can see, all parameters from this section duplicate behat tool options. You can redefine behat formatter defaults here. Also, this is the place to specify parameters for your custom formatters.
The behat tool options are explained when running behat --help.

Related

karate| env specific config file

karate framework| I am trying to create multiple karate-config.js file for different env like 'test', 'stage' can somebody help me with an example how I can call env specific config values from different karate config file.
I refer this https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/karate-config-contract.js
but doesn't clarify what exactly need to do for calling different config.
This part of the karate documentation explains how to check the karate.env property in your karate-config.js in order to set configurations and variables depending on your environment.
An other way to archive different configurations per environment is explained here: environment-specific-config
All these approaches solves the issue, to configure different urls for example in your test cases.
Hence, there is no need to call or check for the environment in your feature file in order to get different configuration values. It's done by karate. Just refer to the variables you assigned in karate-config.js.
You just do something like:
Background:
* url baseUrls.userSystem
Where your karate-config.js could look like:
function fn() {
if (!env) {
env = 'local';
}
var config = {
baseUrls : {
userSystem : "http://localhost"
}
}
if (env === 'dev') {
config.baseUrls.userSystem = "http://usersystem.default.svc"
}
return config
}
The approach above demonstrate how to use just one karate-config.js for all enviroments. One file for all.
If you want to create a karate-config-<env>.js per enviroment, follow the environment-specific-config documentation.
You will find here https://github.com/intuit/karate/tree/master/karate-demo/src/test/java a default karate-config.js that will be evaluated for every environment. The karate-config-contract.js will only be evaluated after the karate-config.js file has been evaluated if and only if the karate.env property is contract.
Please read the karate documentation. Peter did a great job to document nearly every little feature karate offers.

Magento 2 less workflow suggestions

I'm having a hard time locating specific style rules in less, what is the ideal workflow for quickly finding and modifying the rules and structure of the default less files?
The Magento Documentation is pretty helpful here - http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/css-topics/css_debug.html
Source maps are probably the best LESS debugging tool.
For client side compilation configure options in lib/web/less/config.less.js.
The option you want is:
dumpLineNumbers
Type: String Options: ''| 'comments'|'mediaquery'|'all' Default: ''
When set, this adds source line information to the output css file. This helps you debug where a particular rule came from.
- http://lesscss.org/usage/#using-less-in-the-browser
If you want server side compilation, you can use grunt which is built in to Magento 2. Checkout the dev/tools/grunt/configs/less.js file, it shows
var lessOptions = {
options: {
sourceMap: true,
strictImports: false,
sourceMapRootpath: '/',
dumpLineNumbers: false, // use 'comments' instead false to output
...
The documentation will step you through using Grunt, or setting up client side less compilation.

What is the purpose, and proper use of wantTo() in Codeception?

I'm using the testing framework Codeception to do BDD. I understand the idea of wanting something, but I don't understand what the function does.
$I->wantTo('Understand what this method does!');
http://codeception.com/docs/03-AcceptanceTests#Comments
Commands like amGoingTo, expect, expectTo help you in making tests
more descriptive.
$I->wantTo('Understand what this method does!');
will be rendered as * I want to understand what this method does! in verbose output.
Update 2022-11-16:
My original answer was incorrect, wantTo is not a comment method, it renames test method in the output.
Example:
I created very simple Cest class:
<?php
class ExampleCest
{
public function provideExample(CliGuy $I)
{
}
}
When I ran it, I got the following output:
Cli Tests (1) --------------------------------------------
U ExampleCest: Provide example (0.00s)
---------------------------------------------------------
but after adding $I->wantTo('change test name!'); to method:
I got the following output:
Cli Tests (1) --------------------------------------------
U ExampleCest: Change test name! (0.00s)
---------------------------------------------------------
The benefit of wantTo is that it allows to use characters not permitted in method names or different formatting than automatically generated.
I looked up if wantTo has any documentation and all I found was old blog post using examples in class-less Cept format (which is deprecated and is likely to be removed in Codeception 6).
<?php
$I = new TestGuy($scenario);
$I->wantTo('log in to site');
$I->amOnPage('/');
$I->click('Login');
$I->fillField('username', 'admin');
In Cept format wantTo had better purpose, because it didn't override anything, but provided additional information next to file name.

Protractor - How to separate each test to one file and separate variabiles

I have some komplex protractor test written but everything is in one file.
Where I'm on top of it loading all variabiles like:
var userLogin = "John";
and after that somewhere in code I use it together.
What I need to do is
1. Separate all variabiles to aditional file (some config file)
2. Each test to one file
1- I try to make config.js where I add all variabiles and i required it in protractor.conf.js it load correctly problem is that when i use any of this variabiles in some test it's not working (test fail with "userName is not defined")
I know there is a way where i requre config.file in each test script but that's really not best option in my eyes.
2- How can I know what I did in last script if it's separate, like for example how to know I am logged in?
Thanks.
There are multiple things you can make use of.
2) How can I know what I did in last script if it's separate, like for example how to know I am logged in?
This is where beforeEach(), afterEach() can help:
To help a test suite DRY up any duplicated setup and teardown code,
Jasmine provides the global beforeEach and afterEach functions. As the
name implies, the beforeEach function is called once before each spec
in the describe is run, and the afterEach function is called once
after each spec.
There are also beforeAll(), afterAll() available in jasmine 2, or via jasmine-beforeAll third-party for jasmine 1:
The beforeAll function is called only once before all the specs in
describe are run, and the afterAll function is called after all specs
finish. These functions can be used to speed up test suites with
expensive setup and teardown.
1) I try to make config.js where I add all variabiles and i required
it in protractor.conf.js it load correctly problem is that when i use
any of this variabiles in some test it's not working (test fail with
"userName is not defined") I know there is a way where i requre
config.file in each test script but that's really not best option in
my eyes.
One option which I've personally used would be to create a config.js file with all the reusable configuration variables you would need in multiple tests and require the file once - in the protractor config - then set it as a params configuration key value:
var config = require("./config.js");
exports.config = {
...
params: config,
...
};
where config.js is, for example:
var config;
config = {
user: {
login: "user",
password: "password"
}
};
module.exports = config;
Then, you would not need to require config.js in every test, but instead, you'll use browser.params. For example:
expect(browser.params.user.login).toEqual("user");
Also, if you need some sort of a global test preparation step, you can do it in onPrepare() function, see Setting Up the System Under Test. Example configuration that performs a "global" login step is available here.
And an another quick note: you can have custom globally defined variables (like built-in browser or protractor), set them using global in onPrepare. For example, I've defined protractor.ExpectedConditions as a custom global variable:
onPrepare: function () {
global.EC = protractor.ExpectedConditions;
}
Then, in tests, don't require anything, `EC variable would be available in the scope, e.g.:
browser.wait(EC.invisibilityOf(scope.page.dropdown), 5000)
Also, organizing your tests using "Page Object Pattern" would also help to solve the reusability and modularity problem.

Rails 3 - how to use an environment-specific configuration in haml partial

Following the answer on How to define custom configuration variables in rails, I am trying to set up a configuration settings for different environments in config/environments/{env}.rb
e.g. in development.rb I set
config.elvis = 'alive'
and then in my haml template I can use this variable, e.g.
Elvis is #{Rails.configuration.elvis}.
However, when I want to wrap this in a condition:
- if Rails.configuration.elvis
<p>Elvis is #{Rails.configuration.elvis}</p>
it also works, but if the configuration isn't set, it throws a undefined method error.
If I try instead:
- if defined? Rails.configuration.elvis
<p>Elvis is #{Rails.configuration.elvis}</p>
it seems to always evaluate as false, even with the configuration defined.
Still very new to rails/ruby, so apologies if it's a very dumb question
You could use respond_to?:
- if Rails.configuration.respond_to?(:elvis)
<p>Elvis is #{Rails.configuration.elvis}</p>