Matt Wynne | 27 Nov 22:40 2014
Picon

[Cucumber] Re: cucumber > 2.0.0

Hi Ralf,

The release is mostly an internal clean-up, with major parts being re-written for this release. We’re
aiming to achieve backwards compatibility however.

The major new feature is that you can now randomize scenarios in 2.0, avoiding headaches with scenarios
that depend on one another.

Once 2.0 is out, I’d expect we’ll see a steadier pace of new features as the codebase will be easier to
work on.

On 27 Nov 2014, at 14:50, Ralf Claassens <ralfclaassens@...> wrote:

> Hi Matt,
> 
> 
> I'm using Cucumber for quite a while already, and wondering what the upcoming features will be in the >
2.0.0 release? Where can I find these changes / release notes?
> 
> Kind regards,
> 
> Ralf

cheers,
Matt

---
matt@...

--

-- 
(Continue reading)

Julie May | 27 Nov 03:17 2014
Picon

[Cucumber] Gherkin error: Ruby 1.8.7: Cucumber: 1.3.17 WARNING: no such file to load -- 1.8/gherkin_lexer_en

Hello,

I am attempting to update an old Ruby 1.8.7 cucumber testing suite. I realize this is ancient and 1.8.7  is not supported in Cucumber 2.x. However, all indications were that it is supported in cucumber 1.3.17

However, I wanted to update in increments. The idea being to go to the highest cucumber supported, then move to version 2 once the previous bugs were fixed.

The trouble occurs when I update Gherkin. All of sudden the lexer fails to load. 

I tried uninstalling Gherkin and cucumber, then re-installing. 
I tried re-installing just gherkin as was suggested in a previous post, then re-installing

I've included the gem list after the error message.

System: Windows 7 x64, ruby 1.8.7 i386-mingw32, and cucumber last worked when it was version 1.1.9

*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansi
on/) to get coloured output on Windows
WARNING: no such file to load -- 1.8/gherkin_lexer_en
Couldn't load 1.8/gherkin_lexer_en
The $LOAD_PATH was:
lib
C:/Ruby187/lib/ruby/gems/1.8/gems/cucumber-1.3.17/bin/../lib
C:/Ruby187/lib/ruby/gems/1.8/gems/diff-lcs-1.1.3/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/multi_json-1.10.1/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/gherkin-2.12.2-x86-mingw32/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/multi_test-0.1.1/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/cucumber-1.3.17/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/json-1.7.5/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/chronic-0.10.2/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/rubyzip-0.9.9/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/websocket-1.0.7/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.35.1/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/childprocess-0.5.5/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/ffi-1.9.6-x86-mingw32/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/nokogiri-1.5.9-x86-mingw32/lib
C:/Ruby187/lib/ruby/site_ruby/1.8
C:/Ruby187/lib/ruby/site_ruby/1.8/i386-msvcrt
C:/Ruby187/lib/ruby/site_ruby
C:/Ruby187/lib/ruby/vendor_ruby/1.8
C:/Ruby187/lib/ruby/vendor_ruby/1.8/i386-msvcrt
C:/Ruby187/lib/ruby/vendor_ruby
C:/Ruby187/lib/ruby/1.8
C:/Ruby187/lib/ruby/1.8/i386-mingw32
.. Reverting to Ruby lexer.
No lexer was found for en (no such file to load -- gherkin/lexer/en). Supported
languages are listed in gherkin/i18n.json. (Gherkin::I18n::LexerNotFound)
C:/Ruby187/lib/ruby/gems/1.8/gems/gherkin-2.12.2-x86-mingw32/lib/gherkin/i18n.r
:108:in `lexer'
C:/Ruby187/lib/ruby/gems/1.8/gems/gherkin-2.12.2-x86-mingw32/lib/gherkin/parser
parser.rb:139:in `transition_table'
C:/Ruby187/lib/ruby/gems/1.8/gems/gherkin-2.12.2-x86-mingw32/lib/gherkin/parser
parser.rb:128:in `build_transition_map'
C:/Ruby187/lib/ruby/gems/1.8/gems/gherkin-2.12.2-x86-mingw32/lib/gherkin/parser
parser.rb:124:in `transition_map'
C:/Ruby187/lib/ruby/gems/1.8/gems/gherkin-2.12.2-x86-mingw32/lib/gherkin/parser
parser.rb:91:in `initialize'
C:/Ruby187/lib/ruby/gems/1.8/gems/gherkin-2.12.2-x86-mingw32/lib/gherkin/parser
parser.rb:68:in `new'
C:/Ruby187/lib/ruby/gems/1.8/gems/gherkin-2.12.2-x86-mingw32/lib/gherkin/parser
parser.rb:68:in `push_machine'
C:/Ruby187/lib/ruby/gems/1.8/gems/gherkin-2.12.2-x86-mingw32/lib/gherkin/parser
parser.rb:31:in `parse'
C:/Ruby187/lib/ruby/gems/1.8/gems/cucumber-1.3.17/bin/../lib/cucumber/feature_f
le.rb:37:in `parse'
C:/Ruby187/lib/ruby/gems/1.8/gems/cucumber-1.3.17/bin/../lib/cucumber/runtime/f
atures_loader.rb:28:in `load'
C:/Ruby187/lib/ruby/gems/1.8/gems/cucumber-1.3.17/bin/../lib/cucumber/runtime/f
atures_loader.rb:26:in `each'
C:/Ruby187/lib/ruby/gems/1.8/gems/cucumber-1.3.17/bin/../lib/cucumber/runtime/f
atures_loader.rb:26:in `load'
C:/Ruby187/lib/ruby/gems/1.8/gems/cucumber-1.3.17/bin/../lib/cucumber/runtime/f
atures_loader.rb:14:in `features'
C:/Ruby187/lib/ruby/gems/1.8/gems/cucumber-1.3.17/bin/../lib/cucumber/runtime.r
:179:in `features'
C:/Ruby187/lib/ruby/gems/1.8/gems/cucumber-1.3.17/bin/../lib/cucumber/runtime.r
:49:in `run!'
C:/Ruby187/lib/ruby/gems/1.8/gems/cucumber-1.3.17/bin/../lib/cucumber/cli/main.
b:47:in `execute!'
C:/Ruby187/lib/ruby/gems/1.8/gems/cucumber-1.3.17/bin/cucumber:13
C:/Ruby187/bin/cucumber:19:in `load'
C:/Ruby187/bin/cucumber:19



The local gems are:
*** LOCAL GEMS ***

builder (3.2.2, 3.1.4)
bundler (1.5.3)
childprocess (0.5.5, 0.3.6)
chronic (0.10.2)
coderay (1.1.0)
cucumber (1.3.17)
diff-lcs (1.1.3)
ffi (1.9.6 x86-mingw32, 1.0.11)
gherkin (2.12.2 x86-mingw32)
json (1.7.5)
method_source (0.8.2)
multi_json (1.10.1, 1.0.4)
multi_test (0.1.1)
nokogiri (1.5.9 x86-mingw32)
pry (0.10.1 i386-mingw32)
rspec (2.8.0)
rspec-core (2.8.0)
rspec-expectations (2.8.0)
rspec-mocks (2.8.0)
rubyzip (0.9.9)
selenium-webdriver (2.35.1)
slop (3.6.0)
term-ansicolor (1.0.7)
websocket (1.0.7)
win32console (1.3.2 x86-mingw32)

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
aslak hellesoy | 26 Nov 15:53 2014
Picon

[Cucumber] Cucumber School - free episode

Hi all,

We just made the first episode of Cucumber School available for free:

Let us know what you think!

Aslak

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Antonio Terreno | 25 Nov 11:18 2014
Picon

[Cucumber] [js] Cucumber-js testing rest api approach

Hi all, 
I am testing (end2end) a third party system with Cucumber.Js and I'd just like to have a bit of feedback on my approach as there are few things I am not entirely happy with. 

The main 'pain' point is doing http requests, my code looks like (simplified, domain concepts taken off!) : 

  this.When(/^I do request a request with some params$/,

    function (params, callback) {

      var xml = this.template.compile(template, params);

      this.session.params = params;
      this.request.post(this.env.endpoint, this, xml, callback);      
    });

Pairing with a colleague I've noticed he wrote callback() again after this line, which lead to not wait for the response being completed, the request module looks more or less like this: 

module.exports = {
  post: function (endpoint, self, body, callback) {    
    request.post({
        headers: {
          'apikey': self.env.apikey
        },
        url: self.env.baseUrl + endpoint,
        body: body
      },
      function (error, response, body) {
        if (!error && response.statusCode === 200) {
          self.session.lastBody = body;                    
          callback();
        } else {
          callback.fail(error);
        }

Is that a decent approach? I definitely want to isolate the http status code and error logic in one place. 

The other, minor, pain point is the use of should, I have few expectations on the When and should throws exceptions when failing, cucumber-js catches them and fail, all good, but massive stack traces go on the console, errors are repeated on the console twice... 

Do I have to extend should, passing by the callback and wrap them in a try catch to get a better, more readable result? (I am looking into more or less what I get when I run chai for example...)

Thanks for reading, 
cheers

toni

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Christian | 24 Nov 13:39 2014
Picon

[Cucumber] [cucumber-jvm] How do I directly jump from a step in Eclipse's JUnit pane to the step definition?

Hi! 

Is there a way to jump from the JUnit pane in Eclipse (listing the (executed) steps from the feature file) directly to the implementing Java step definition, e.g. by double-clicking it?

I know IntelliJ supports this, and I do have the cucumber-eclipse plugin installed, but I get an error message "Cannot open Editor - Test class not found in selected project" when I try in Eclipse...

Brgrds,

Christian

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Christian | 21 Nov 10:19 2014
Picon

[Cucumber] [cucumber-jvm] How do I execute only one step definitions file from a package containing several?

Hi!

Is there a way to just specify one step defs (hooks) file from a package containing several?

<at> CucumberOptions(glue = {
        "com.example.cucumber.hooks.Foo",
        "com.example.cucumber.hooks.Foo.class" })

Neither of these options seem to work; the stepdef file just doesn't get executed...
If I provide only the path up to the hooks package, it does get loaded - but also other hook files that I don't want...

Brgrds,

Christian

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Christian | 20 Nov 11:35 2014
Picon

[Cucumber] [Eclipse] Toggle comments in Gherkin feature files with keyboard shortcut?

Hi all,

Is there a way to make Eclipse toggle comments in Gherkin feature files using a keyboard binding, such as Ctrl + Shift + / ?
I have the Cucumber-Eclipse plugin installed, but I guess that won't make too much a difference?

Brgrds,

Christian

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Biswajit Samal | 20 Nov 10:09 2014
Picon

[Cucumber] How to run my script using pageobject model + Selenium+ cucumber JVM

Respected All,

I want to run my test using page object model I have followed the below steps:-

1.  My NavigationStepDef is:-


private Login login;
private Company company;
static WebDriver driver;

public NavigationStepdefs(SharedDriver driver) {
this.driver = driver;
login = new Login(driver);
company =  new Company(driver);
}
/**
* ===============================================  LOGIN STEP DEFINITION  =================================================
*/

<at> Given("^the login page is open \"(.*?)\"$")
public void the_login_page_is_open(String URl) throws Throwable {
// Write code here that turns the phrase above into concrete actions
driver.get(URl);
}

<at> When("^I fill in UserName with \"(.*?)\"$")
public void i_fill_in_UserName_with(String userName) throws Throwable {
// Write code here that turns the phrase above into concrete actions
login.enterUserName(userName);
}

<at> When("^I fill in password with \"(.*?)\"$")
public void i_fill_in_password_with(String password) throws Throwable {
// Write code here that turns the phrase above into concrete actions
login.enterPassword(password);
}

<at> When("^I click on login button$")
public void i_click_on_login_button() throws Throwable {
// Write code here that turns the phrase above into concrete actions
login.clickLoginButton();
}

<at> Then("^I should see the result$")
public void i_should_see_the_result() throws Throwable {
// Write code here that turns the phrase above into concrete actions
Assert.assertTrue(driver.getCurrentUrl().equals("Dashboard page"));
}
/**
*    =========================================  COMPANY STEP DEFINITION  =================================================
*    
*/
<at> Given("^I am in company page$")
public void i_am_in_company_page() throws Throwable {
   // Write code here that turns the phrase above into concrete actions
   company.companyPage();
}

<at> When("^I enter data in field Company Type with \"(.*?)\"$")
public void i_enter_data_in_field_Company_Type_with(String companyType) throws Throwable {
   // Write code here that turns the phrase above into concrete actions
   company.companyType(companyType);
}

<at> When("^I enter data in field Company Name with \"(.*?)\"$")
public void i_enter_data_in_field_Company_Name_with(String companyName) throws Throwable {
   // Write code here that turns the phrase above into concrete actions
   company.companyName(companyName);
}

<at> When("^I enter data in field Company Code with \"(.*?)\"$")
public void i_enter_data_in_field_Company_Code_with(String companyCode) throws Throwable {
   // Write code here that turns the phrase above into concrete actions
   company.companyCode(companyCode);
}

<at> When("^I enter data in field Number Of Employee with \"(.*?)\"$")
public void i_enter_data_in_field_Number_Of_Employee_with(String companyNumberOfEmployee) throws Throwable {
   // Write code here that turns the phrase above into concrete actions
   company.companyNumberOfEmployee(companyNumberOfEmployee);
}

<at> When("^I enter data in field Tax Ref Number with \"(.*?)\"$")
public void i_enter_data_in_field_Tax_Ref_Number_with(String companyTaxRefNo) throws Throwable {
   // Write code here that turns the phrase above into concrete actions
   company.companyTaxRefNo(companyTaxRefNo);
}

<at> When("^I enter data in field Annual Turnover with \"(.*?)\"$")
public void i_enter_data_in_field_Annual_Turnover_with(String companyAnnualTurnover) throws Throwable {
   // Write code here that turns the phrase above into concrete actions
   company.companyAnnualTurnover(companyAnnualTurnover);
}

<at> When("^I enter data in field URL with \"(.*?)\"$")
public void i_enter_data_in_field_URL_with(String companyURL) throws Throwable {
   // Write code here that turns the phrase above into concrete actions
   company.companyURL(companyURL);
}

<at> When("^I enter data in field Currency with \"(.*?)\"$")
public void i_enter_data_in_field_Currency_with(String companyCurrency) throws Throwable {
   // Write code here that turns the phrase above into concrete actions
   company.companyCurrency(companyCurrency);
}

<at> When("^Click on CompanyStore button$")
public void click_on_CompanyStore_button() throws Throwable {
   // Write code here that turns the phrase above into concrete actions
   company.companyStoreButton();
}

<at> Then("^I should see success message$")
public void i_should_see_success_message() throws Throwable {
   // Write code here that turns the phrase above into concrete actions
   Assert.assertTrue(driver.getPageSource().contains(" successfully "));
}


2. My Company page is :-


public WebDriver driver;
private static final long TimeOut = 3000;
public Company(WebDriver driver) {
this.driver = driver;
}

/**
* <at> param ==========================================  COMPANY DETAILS  =====================================================
* <at> throws InterruptedException 
*/
public void companyPage() throws InterruptedException{
WebElement companyMenulink = driver.findElement(By.linkText("Company"));
WebElement companySubMenulink = driver.findElement(By
.xpath(".//*[ <at> id='headerPan']/div[4]/ul/li[1]/ul/li[2]/a"));

Actions actions = new Actions(driver);
actions.moveToElement(companyMenulink);

actions.moveToElement(companySubMenulink);
actions.build().perform();
driver.get("Company URL");
//wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("")));
Thread.sleep(TimeOut);
}
public void companyType(String companyType) {
Select sel = new Select(driver.findElement(By
.id("StoreForm-Company_actionbean_company_type")));
sel.selectByVisibleText(companyType);
}

public void companyName(String companyName) {
driver.findElement(By.id("StoreForm-Company_actionbean_company_name"))
.sendKeys(companyName);
}
public void companyCode(String companyCode){
driver.findElement(By.id("StoreForm-Company_actionbean_company_code")).sendKeys(companyCode);
}
public void companyNumberOfEmployee(String companyNumberOfEmployee){
driver.findElement(By.id("StoreForm-Company_actionbean_company_numOfEmployees")).sendKeys(companyNumberOfEmployee);
}
public void companyTaxRefNo(String companyTaxRefNo){
driver.findElement(By.id("StoreForm-Company_actionbean_company_taxRefNo")).sendKeys(companyTaxRefNo);
}
public void companyAnnualTurnover(String companyAnnualTurnover){
driver.findElement(By.id("StoreForm-Company_actionbean_company_annualTurnover")).clear();
driver.findElement(By.id("StoreForm-Company_actionbean_company_annualTurnover")).sendKeys(companyAnnualTurnover);
}
public void companyURL(String companyURL){
driver.findElement(By.id("StoreForm-Company_actionbean_company_webUrl")).sendKeys(companyURL);
}
public void companyCurrency(String companyCurrency){
Select sel =  new Select(driver.findElement(By.id("StoreForm-Company_actionbean_company_currencyId")));
sel.selectByVisibleText(companyCurrency);
}
public void companyStoreButton() throws InterruptedException{
WebElement element = driver.findElement(By
.xpath("//ul[ <at> id='tools']/li[2]/a/span"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);
        driver.findElement(By.xpath("*//button[1]/span")).click();
Thread.sleep(TimeOut);
}
3.  Cucumber feature is:-

Feature: Login to the system
  As an user,  I want to login into the system when I  provide username and password.

  Scenario Outline: Verify that user login
    Given the login page is open "**********"
    When I fill in UserName with "<UserName>"
    And I fill in password with "<Password>"
    And I click on login button
    Then I should see the result

    Scenarios: 
      | UserName | Password |
      | ************ | ************|
      
       Scenario Outline: Create a company
    Given I am in company page
    When I enter data in field Company Type with "<companyType>"
    And I enter data in field Company Name with "<CompanyName>"
    And I enter data in field Company Code with "<CompanyCode>"
    And I enter data in field Number Of Employee with "<NumberOfEmployee>"
    And I enter data in field Tax Ref Number with "<TaxRefNumber>"
    And I enter data in field Annual Turnover with "<AnulTurnover>"
    And I enter data in field URL with "<URL>"
    And I enter data in field Currency with "<Currency>"
    When Click on CompanyStore button
    Then I should see success message

    Scenarios: 
      | companyType | CompanyName | CompanyCode | NumberOfEmployee | TaxRefNumber | AnulTurnover | URL                    | Currency             |
      | Customer    | AOM Ltd     | AOM007      | 100              | 123          | 1000cr       | https://www.aomltd.com | INR ( Indian Rupee ) |
      
Then My problem is
1. I can login to the application
2. But when I want to navigate to Company Page, there it showing an error element is not able to locate.
3. When I run the same script with out using pageobject model it runs fine.


Please rectify me.. I am in urgent to finish a task friend.. Please help.


--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Peter Wilson | 20 Nov 00:50 2014
Picon

[Cucumber] Cucumber - Enterprise Level

Hi,

We've been using cucumber for about 6 months now and have found it very beneficial.

We're now looking to take it to a larger scale, with tens of thousands of tests and need a better test, infrastructure and data management system.

I've put together a high level mud map of what I am thinking and would really value feedback from the group. For example, has this already been done, or thought about and discarded for some reason.

To summarize:
1. Feature file goes into the test manager (a server of some sort) which chops up the scenarios (being aware of the background) and farms it out to different cucumber nodes.  It stores results of each execution of each step in the test management DB, along with how long each step takes and what test data it required
2. The Cucumber Hub is like the Selenium Hub.  Cucumber Nodes register with it and advertise test functions that it supports
3. The Cucumber Node is a cucumber file (step definition and on, not the Gherkin) turned into a service.  A scenarios is passed to the node, the node executes and returns the result
4. The Data Manager looks after test data for different environments.  It tracks daily usage and individual test usage and tries to create the necessary test data predictively ahead of time.  The cucumber node will call the data manager as part of any data "given"
5. The Selenium hub we already know about
6. The Node Manager monitors the hubs looking at utilization levels and starts new cucumber and selenium nodes in a cloud service (such as Amazon) as required.

Another important piece that I am heading towards here is using this model for performance testing.  This would reduce the cost of performance testing because no expensive tools or specialized scripts are required.  It would also mean performance testing can be done as soon as the functional scripts are complete, which means it can be done earlier.  One set of scripts reduces maintenance costs as well. 
Having detailed information about scenario and step run times and data requirements would make performance testing pretty easy to setup too.

That's it.

Cheers
Peter



--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Pravakar Panigrahi | 19 Nov 10:00 2014
Picon

[Cucumber] [JVM] how to get the name of the feature file being executed

I have a scenario, where depending on the feature file being executed, I need to initialize a .properties file. There are multiple feature files in my test folder which will be executed.Is there any way, by which, I will be able to know the feature file being executed?

Thanks,
Pravakar

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Philip Black-Knight | 17 Nov 23:54 2014

[Cucumber] [JVM, Groovy] best practices regarding data base access and cleanup

I'd like to be able to crate users and other domain objects in the fly within my cucumber tests. We are using
cucumber-groovy (+GEB for browser automation) to test a Java/struts2 site. I'm able to access our
services from cucumber with no problem, but I'm wondering if there are any best practices to for cleanimg
up the DB after tests. I would love to be able to recreate the dB between scenarios, but that just isn't an
option at the moment....

 I've created some helper functions to create uses with roles specified in feature, e.g.

Given I login as a user with the roles:
 |role a|role b| role c|
when xxx
then yyy

I'm currentry using the same user name every time, and if the user already exists, I delete it before
creating the new one.  I would like to be able to leave things in a clean state after every test, but I'm not
sure how to go about it.  I've implemented the method to create users as part of a class that gets added to the world:

World {new UserUtils () }

In addition to adding a helper to create the user, the utilitiy class adds a reference to the service and
(when the user is created) a user object on the world, so step definitions can do:
 page.password.value = user.password
And the user gets propagated to every step.

I can see adding a number of these helpers for different domain types, so I'm wondering if there is a way to
register an After() hook when UserUtils is registered with the world.

Or is there another approach that I'm not thinking of. I don't think tags on the scenario will work since I
need different roles (or other parameters set on the user) for different tests, and these are really
'Given' conditions.

It feels like there should be another way to deal with this without having a bunch of After() hooks that check
for the existence of these properties....

Phil

--

-- 
Posting rules: http://cukes.info/posting-rules.html
--- 
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.


Gmane