Re: [rspec-users] Cucumber/RSpec for an existing Rails project - generate rspec models and controllers?

2009-04-26 Thread David Chelimsky
On Sun, Apr 26, 2009 at 1:47 AM, Lee Longmore  wrote:
>
> Hi,
>
> I would like to use Cucumber and RSpec for my existing Rails project.
>
> I am now reasonably comfortable with the use of these, having studied the
> RSpec Book and various online resources. I am however unsure about one
> thing...
>
> Given that I have several existing models and controllers in my code base,
> how do I synch RSpec with these?
>
> That is, do I need to generate RSpec models and controllers for each of
> these existing models and controllers?

If you already have code in place, I would recommend adding specs by
hand instead of using the generators.

> If so, is there I anything I should be aware of when doing so?

Back-filling specs onto pre-existing code is a very different animal
from driving out code with specs first. There is a book called Working
Effectively with Legacy Code by Michael Feathers that deals with this
topic very thoroughly. You might not think what you have is legacy
code, but Michael (actually, Erik Meade, but in the WELC book),
defines legacy code as any code without tests.

Part of the premise of TDD (with a T) is that by writing tests and
code in a tight cycle (small bit of test, small bit of code to make it
pass, refactor), the resulting code is inherently testable. When
you're backfilling tests, this is not necessarily the case. So the
trick is to add the tests slowly, and *pay attention to the code* as
you're doing so. If something is hard to test then use the opportunity
to make it easier to test.

Of course doing so is refactoring without tests, which is something to
be avoided. So you've got a catch 22. And that's where the legacy code
book can really help, as it offers a number of techniques and
strategies to address this problem. So I'd recommend picking that up.

Short of buying the book, the basic idea is that whenever you're
modifying your existing code, find all the high level features that
might be impacted and add cucumber scenarios for them first. Once
those are in place, drive out the changes and/or new code spec first.
With this strategy, you'll gradually improve the code base by getting
it under test and refactoring as you go. This is more pain-staking
than doing a one-time full coverage sort of thing, but in the end the
result is going to be cleaner and better for you (and probably less
work in the long run).

Cheers,
David

>
> Many thanks,
>
> Lee.
>
> mobile: +44(0)775 392 8067
> home: +44(0) 208 8358256
> email:   lee_longm...@yahoo.co.uk
>
>
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] jruby require 'jcode' problem and cucumber 1.2.0

2009-04-26 Thread aslak hellesoy
> After upgrading to cucumber 0.3.0 from 0.1.16 I'm getting this error when I
> try to run a feature:
> /Users/steve/src/jruby-1.2.0/lib/ruby/1.8/jcode.rb:66:in `end_regexp': too
> short multibyte code string:
> /[\xc0-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf][\x80-\xbf]$/ (RegexpError)
>  from /Users/steve/src/jruby-1.2.0/lib/ruby/1.8/jcode.rb:79:in `succ!'
> from /Users/steve/src/jruby-1.2.0/lib/ruby/1.8/jcode.rb:94:in `succ'
>  from
> /Users/steve/mercy/webpresence/vendor/gems/activeldap-1.0.2/lib/active_ldap/user_password.rb:81:in
> `each'
> from
> /Users/steve/mercy/webpresence/vendor/gems/activeldap-1.0.2/lib/active_ldap/user_password.rb:81:in
> `to_a'
>  from
> /Users/steve/mercy/webpresence/vendor/gems/activeldap-1.0.2/lib/active_ldap/user_password.rb:81
> from
> /Users/steve/mercy/webpresence/vendor/gems/activeldap-1.0.2/lib/active_ldap/user_password.rb:80:in
> `collect'
>  from
> /Users/steve/mercy/webpresence/vendor/gems/activeldap-1.0.2/lib/active_ldap/user_password.rb:80
> from
> /Users/steve/mercy/webpresence/vendor/gems/activeldap-1.0.2/lib/active_ldap/user_password.rb:31:in
> `require'
>  ... 27 levels...
> from
> /Users/steve/src/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/cucumber:6
>  from
> /Users/steve/src/jruby-1.2.0/lib/ruby/gems/1.8/gems/cucumber-0.3.0/bin/cucumber:19:in
> `load'
> from /Users/steve/src/jruby-1.2.0/bin/cucumber:19
>
> It's this open Jruby issue:
>
> http://jira.codehaus.org/browse/JRUBY-2964
>
> Anyone have a workaround?  I'm running jruby 1.2.0, java 1.5.0_16 on OS X
> leopard.
>

Don't require jcode and replace any occurrances of #jlength with #length
should work. Monkey patch if you have to.

Aslak


>
> Thanks.
>
> Steve
>
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] BDD for C#?

2009-04-26 Thread aslak hellesoy
On Sun, Apr 26, 2009 at 7:06 AM, Phlip  wrote:

> Brandon Olivares wrote:
>
>  I know this is slightly off topic, but I'm having trouble finding
>> something,
>> and wondered if anyone here had experience with any BDD frameworks
>> for C#.
>>
>
> Why not replicate Cucumber in C#?
>

Cucumber has been working with .NET for a while:
http://wiki.github.com/aslakhellesoy/cucumber/ironruby-and-net

IronRuby was really slow last time I tried (4-5 months ago), so unless it
has improved its speed it will be too slow for practical use. On the other
hand, if IronRuby matures, Cucumber should work well with .NET. It already
does for Java (using JRuby).

I recently added pure java support to Cucumber, meaning steps can be written
in Java instead of Ruby.
http://github.com/aslakhellesoy/cucumber_java/tree/master

This obviously makes it easier to use for Java programmers. It should be
fairly easy to implement similar pure C# support. But a quicker IronRuby is
still needed.

Aslak


>
> Not port or link, replicate. It's only like ~10 features, right? I don't
> know C#, but I could do it in C++ in a couple days.
>
> --
>  Phlip
>  http://flea.sourceforge.net/resume.html
>
>
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] BDD for C#?

2009-04-26 Thread aslak hellesoy
On Sun, Apr 26, 2009 at 12:32 PM, aslak hellesoy
wrote:

>
>
> On Sun, Apr 26, 2009 at 7:06 AM, Phlip  wrote:
>
>> Brandon Olivares wrote:
>>
>>  I know this is slightly off topic, but I'm having trouble finding
>>> something,
>>> and wondered if anyone here had experience with any BDD frameworks
>>> for C#.
>>>
>>
>> Why not replicate Cucumber in C#?
>>
>
> Cucumber has been working with .NET for a while:
> http://wiki.github.com/aslakhellesoy/cucumber/ironruby-and-net
>
> IronRuby was really slow last time I tried (4-5 months ago), so unless it
> has improved its speed it will be too slow for practical use. On the other
> hand, if IronRuby matures, Cucumber should work well with .NET. It already
> does for Java (using JRuby).
>
> I recently added pure java support to Cucumber, meaning steps can be
> written in Java instead of Ruby.
> http://github.com/aslakhellesoy/cucumber_java/tree/master
>
> This obviously makes it easier to use for Java programmers. It should be
> fairly easy to implement similar pure C# support. But a quicker IronRuby is
> still needed.
>

And a more stable one it seems:
http://twitter.com/niclasnilsson/statuses/1605950974


>
> Aslak
>
>
>>
>> Not port or link, replicate. It's only like ~10 features, right? I don't
>> know C#, but I could do it in C++ in a couple days.
>>
>> --
>>  Phlip
>>  http://flea.sourceforge.net/resume.html
>>
>>
>> ___
>> rspec-users mailing list
>> rspec-users@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
>
>
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

[rspec-users] [Cucumber] gem missing dependencies

2009-04-26 Thread Kero van Gelder
Hi!

Looks like installing hoe (which brings in rubyforge and rake) solved the 
problem below.
Who builds the gem / should I report this to / should I send a patch ?

Bye,
Kero.

---

fresh install of debian lenny, upgraded to unstable.

$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
$ gem -v
1.2.0
$ gem list

*** LOCAL GEMS ***

builder (2.1.2)
cucumber (0.3.0)
diff-lcs (1.1.2)
polyglot (0.2.5)
rspec (1.2.4)
term-ansicolor (1.0.3)
treetop (1.2.5)
$ cucumber
/usr/lib/ruby/1.8/rubygems.rb:578:in `report_activate_error': Could not find 
RubyGem hoe (>= 1.8.0) (Gem::LoadError)
from /usr/lib/ruby/1.8/rubygems.rb:134:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:157:in `each'
from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:157:in `each'
from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:157:in `each'
from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:49:in `gem'
from /var/lib/gems/1.8/bin/cucumber:18

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] [Cucumber] gem missing dependencies

2009-04-26 Thread aslak hellesoy
On Sun, Apr 26, 2009 at 2:16 PM, Kero van Gelder  wrote:
> Hi!
>
> Looks like installing hoe (which brings in rubyforge and rake) solved the 
> problem below.
> Who builds the gem / should I report this to / should I send a patch ?
>

I just fixed that:
http://github.com/aslakhellesoy/cucumber/commit/23cbc9b6c54ebe1ecf568610c2696762f22f0b06

Aslak

> Bye,
> Kero.
>
> ---
>
> fresh install of debian lenny, upgraded to unstable.
>
> $ ruby -v
> ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
> $ gem -v
> 1.2.0
> $ gem list
>
> *** LOCAL GEMS ***
>
> builder (2.1.2)
> cucumber (0.3.0)
> diff-lcs (1.1.2)
> polyglot (0.2.5)
> rspec (1.2.4)
> term-ansicolor (1.0.3)
> treetop (1.2.5)
> $ cucumber
> /usr/lib/ruby/1.8/rubygems.rb:578:in `report_activate_error': Could not find 
> RubyGem hoe (>= 1.8.0) (Gem::LoadError)
>        from /usr/lib/ruby/1.8/rubygems.rb:134:in `activate'
>        from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate'
>        from /usr/lib/ruby/1.8/rubygems.rb:157:in `each'
>        from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate'
>        from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate'
>        from /usr/lib/ruby/1.8/rubygems.rb:157:in `each'
>        from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate'
>        from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate'
>        from /usr/lib/ruby/1.8/rubygems.rb:157:in `each'
>        from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate'
>        from /usr/lib/ruby/1.8/rubygems.rb:49:in `gem'
>        from /var/lib/gems/1.8/bin/cucumber:18
>
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] Problems running features with Textmate Cucumber bundle

2009-04-26 Thread Rick DeNatale
I finally plunked down for the beta RSpec bundle and I'm working
through the initial example.  Although I'm a fairly experienced RSpec
user, I'm stlll learning new tricks.

Anyway,  I'm going though the mastermind example, and everything is
going well, except that I decided to also try out the Textmate bundle
for Cucumber.  I decided to use Ben Mabey's fork on github since it
seems to be the most evolved.

When I try to run a feature with cmd-R, instead of actually running I
see something like:

Running: cucumber
/Users/rick/mastermind/features/codebreaker_starts_game.feature --format=html
false

Cucumber runs fine from bash.

Am I missing some setup?

-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] RSPEC book example in Chapter 3.

2009-04-26 Thread G. Brandon Hoyt
Hi!
I'm going through the rspec book in beta form right now and hit a snag
in chapter three.
I am developing an application in parallel to the book example instead
of writing the book example word for word.  To the best of my knowledge,
I have duplicated a parallel example of the book example, changing what
needed to be changed to fit my example.  Currently, I have a failing
spec when the book says my spec shouldn't be failing.

http://pastie.org/458945
that is the failing spec

here are my system specifications:
OS: Ubuntu 8.10_AMD64
ruby -v ruby 1.8.8p1 (2009-04-09 revision 23162) [x86_64-linux]
rspec -v rspec 1.2.4

http://pastie.org/458949
Here is the actual code that fails the spec.
any ideas?
I think I'm missing a require somewhere, that's what my gut is telling
me.
-- 
***
***
 From G. Brandon Hoyt  
 863-397-7036  
 "Do the RIGHT thang!" 
 --Uncle Kenny 
   
 de KG4GVL clear   
***
***


signature.asc
Description: Digital signature
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

[rspec-users] running a specific feature when set up with selenium

2009-04-26 Thread Barun Singh
I've set up my cucumber.yml file so that i have a default profile and a
selenium profile as described at the end of this wiki page:
http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium

This works great when I run 'cucumber' from the command line, but I don't
seem to be able to run a specific feature by doing something like:
  cucumber features/plain/something.feature

If i run the above command, cucumber just tells me that all of the steps in
my feature are undefined.  This seems to be a simple problem of just being
able to tell the rake tasks where to look to find the necessary files -
perhaps when I try to run a single feature cucumber isn't able to find the
cucumber.yml file (is it expecting to find it in the directory where that
specific feature is?  if so, does that mean i'd have to keep redundant
copies of the .yml file in the root directory and in each directory where i
have features?)

My guess is that others have run into this issue and there should be a
relatively straightforward setup issue I'm neglecting.  Any ideas?

Thanks..
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] RSPEC book example in Chapter 3.

2009-04-26 Thread David Chelimsky
On Sun, Apr 26, 2009 at 3:45 PM, G. Brandon Hoyt  wrote:
> Hi!
> I'm going through the rspec book in beta form right now and hit a snag
> in chapter three.
> I am developing an application in parallel to the book example instead
> of writing the book example word for word.  To the best of my knowledge,
> I have duplicated a parallel example of the book example, changing what
> needed to be changed to fit my example.  Currently, I have a failing
> spec when the book says my spec shouldn't be failing.
>
> http://pastie.org/458945
> that is the failing spec

You've got the message expectation (should_receive) on the wrong
object - it should be on the messenger, not the program.

HTH,
David

>
> here are my system specifications:
> OS: Ubuntu 8.10_AMD64
> ruby -v ruby 1.8.8p1 (2009-04-09 revision 23162) [x86_64-linux]
> rspec -v rspec 1.2.4
>
> http://pastie.org/458949
> Here is the actual code that fails the spec.
> any ideas?
> I think I'm missing a require somewhere, that's what my gut is telling
> me.



> --
> ***
> ***
>                 From G. Brandon Hoyt
>                     863-397-7036
>                 "Do the RIGHT thang!"
>                 --Uncle Kenny
>
>                                 de KG4GVL clear
> ***
> ***
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkn0x+cACgkQf3s7GyRXBzRe1QCeJgBAk6jJX4xinYTZYyQ05ngm
> aGUAn1hU6grPNIXgoTYAW4t79a1qjOdq
> =cn4o
> -END PGP SIGNATURE-
>
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] RSPEC book example in Chapter 3.

2009-04-26 Thread G. Brandon Hoyt
On Sun, Apr 26, 2009 at 04:17:42PM -0500, David Chelimsky wrote:
> You've got the message expectation (should_receive) on the wrong
> object - it should be on the messenger, not the program.
> 
> HTH,
> David

yep that fixed 'er all right!  I don't know ow many times I thought I
had checked it to make sure it was translated accurately, yet there it
was in plain sight!
--
-- 
***
***
** From G. Brandon Hoyt  **
** 863-397-7036  **
** "Do the RIGHT thang!" **
** --Uncle Kenny **
**   **
** de KG4GVL clear   **
***
***


signature.asc
Description: Digital signature
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] Problems running features with Textmate Cucumber bundle

2009-04-26 Thread Ben Mabey

Rick DeNatale wrote:

I finally plunked down for the beta RSpec bundle and I'm working
through the initial example.  Although I'm a fairly experienced RSpec
user, I'm stlll learning new tricks.

Anyway,  I'm going though the mastermind example, and everything is
going well, except that I decided to also try out the Textmate bundle
for Cucumber.  I decided to use Ben Mabey's fork on github since it
seems to be the most evolved.

When I try to run a feature with cmd-R, instead of actually running I
see something like:

Running: cucumber
/Users/rick/mastermind/features/codebreaker_starts_game.feature --format=html
false

Cucumber runs fine from bash.

Am I missing some setup?

  
Hmm.. that is odd. What version of Cucumber are you using?  When you run 
that exact command from the shell does it output the HTML report?


-Ben
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] Cucumber: Setting Dependency among scenarios

2009-04-26 Thread Neema Cheriyath
Hi,
I am planning to use cucumber-java for my java project for automated
testing. I would like to know if there is any option in cucumber, by
which we can explicitly provide dependency among running scenarios. For
example:

I have a ValidateProfile.java and a ProfileSignIn.java.

public class ValidateProfile {
  ...
  public ValidatedProfile validate(String userName, String password) {
...
...
  }
}
public class ProfileSignIn {
  public void doSignIn(ValidatedProfile profile) {
...
...
  }
}

Suppose I have a step definition for ValidateProfile as:
public class ValidateProfileTest {
  @Given("I have user credential as (.*) and (.*)$")
  public void setCredentials(String userName, String password) {
// set credentials to members
...
  }
  @When("I call Validate Profile")
  public void validateProfile() {
...
ValidatedProfile profile = validateProfile.validate(_userName,
_password);
// set profile in class member
...
  }
  @Then("Profile should validate successfully() {
// assert contents of Validated Profile
  }
}

Now I would like to create a Test case, say ProfileSignInTest, for
ProfileSignIn. As ProfileSignIn requires a ValidatedProfile, I would
like to run ValidateProfileTest prior to that and make use of the
ValidatedProfile as input to ProfileSignInTest.

Before running a scenario in ProfileSignInTest's feature(say
profilesignin.feature) , Is there any option to run the features of
ValidateProfileTest(say validateprofile.feature), get its output and
pass the same as input to profilesignin.feature 's scenario as below:

validateprofile.feature
---
@getValidatedProfiles
Given I have a username and password
When I call Validate Profile
Then Profile should validate successfully

profilesignin.feature
-
@profilesignin
use output as validatedProfile from @getValidatedProfiles
Given I have the validated profile as validatedProfile
When I call SignIn
Then I should get Signed In successfully

My idea is to make use of hooks as below, and if possible pass the
output of @getValidatedProfiles to the 'Given' of @profilesSignin. If
that's not possible, I can make use of a java framework to store and
retrieve the output, but the priority is to make a scenario dependent on
one or more other scenarios.

Before('@profilesignin') do
  //run the scenario with tag @getValidatedProfiles
end

Other than hooks, If there are any other better ways of handling
this, please let me know.

Thanks,
Neema
-- 
Posted via http://www.ruby-forum.com/.
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] automating and end to end functional test.

2009-04-26 Thread jmac
Hi David,

So I have a number of Java based web systems. The systems allow users
to lodge applications for various products/services that my
organisation provides. The applications usually have at least 4 or 5
pages, but may be longer depending on the info that is entered. There
is alot of common page fragments between the two systems (eg most
systems have a page with bio info: names, Birth dates, gender etc) but
each system with have different fields in addition the common fields
on each page fragment. So, what I wanted to do is create features for
logon, features to deal with the common page fragments, like the bio
stuff, features to deal with the unique parts, and chain these all
together so that I can build up a test to test the end to end
application process. I will be using either watir or selenium with
rspec/cucumber. The organization currently uses commercial test
automation tools, so I am looking at ditching these and going with a
Ruby based solution.

The cucumber examples I have seen usually are short:
Given..something
Wen .. I do something
Then .. I expect this to happen

Can they be longer like this:

Given..
And..
And..
Then..
And..
And..
And..
And..
Then...
Given..
And..
And..
Then..

etc.
On Apr 25, 11:11 pm, David Chelimsky  wrote:
> On Sat, Apr 25, 2009 at 5:43 AM, jmac  wrote:
> > Hi,
> > I am new to ruby and rspec. I would like to use ruby/rspec/cucumber to
> > automate acceptance tests for a number of integrated systems at my
> > work. I get the basics of cucumber features, but how do I chain these
> > tests so that I can test a process from start to finish. Essentially,
> > I want to use the features as components that I can plug together to
> > create the different tests. Can cucumber/rspec be used this way.
>
> Can you give an example. Something simple, but just complex enough to
> get your goal across. I have an idea of what you're after, but don't
> want to waste my time writing or anybody else's time reading if I'm
> wrong :)
> ___
> rspec-users mailing list
> rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Cucumber: Setting Dependency among scenarios

2009-04-26 Thread aslak hellesoy
> Hi,
>I am planning to use cucumber-java for my java project for automated
> testing. I would like to know if there is any option in cucumber, by
> which we can explicitly provide dependency among running scenarios. For
> example:
>

There is not, and there probably never will be. With any testing framework -
if the outcome of a test A depends on whether or not test B has run before
it - then you have created for yourself (and your team) a formidable time
waster.

Everyone will spend lots of time figuring out why a test is failing under
some circumstances and not under others. Every week there is a new person on
this list asking something like:

"Why do all my (Cucumber/RSpec) tests pass when I run them all with Rake,
but not when I run one individually?"

The answer is always the same:

"Because they are coupled"

Then they go debugging for an hour, sometimes several days and come back
with:

"I finally found out where the coupling is. How can I decouple them?"

If I make it easier for people to run scenarios in a certain order, I also
make give people more rope to hang themselves with. People will inevitably
end up in the situation I just described. And then everybody's time gets
wasted.

Actually - in Cucumber - the objects created in one scenario will never be
available to the next scenario. Of course you can work around this (shoot
yourself in the foot) by storing state in static/class variables or in a
database, but I don't recommend it.


>I have a ValidateProfile.java and a ProfileSignIn.java.
>
>public class ValidateProfile {
>  ...
>  public ValidatedProfile validate(String userName, String password) {
>...
>...
>  }
>}
>public class ProfileSignIn {
>  public void doSignIn(ValidatedProfile profile) {
>...
>...
>  }
>}
>
>Suppose I have a step definition for ValidateProfile as:
>public class ValidateProfileTest {
>  @Given("I have user credential as (.*) and (.*)$")
>  public void setCredentials(String userName, String password) {
>// set credentials to members
>...
>  }
>  @When("I call Validate Profile")
>  public void validateProfile() {
>...
>ValidatedProfile profile = validateProfile.validate(_userName,
> _password);
>// set profile in class member
>...
>  }
>  @Then("Profile should validate successfully() {
>// assert contents of Validated Profile
>  }
>}
>
>Now I would like to create a Test case, say ProfileSignInTest, for
> ProfileSignIn. As ProfileSignIn requires a ValidatedProfile, I would
> like to run ValidateProfileTest prior to that and make use of the
> ValidatedProfile as input to ProfileSignInTest.
>

>Before running a scenario in ProfileSignInTest's feature(say
> profilesignin.feature) , Is there any option to run the features of
> ValidateProfileTest(say validateprofile.feature), get its output and
> pass the same as input to profilesignin.feature 's scenario as below:
>
>validateprofile.feature
>---
>@getValidatedProfiles
>Given I have a username and password
>When I call Validate Profile
>Then Profile should validate successfully
>
>profilesignin.feature
>-
>@profilesignin
>use output as validatedProfile from @getValidatedProfiles
>Given I have the validated profile as validatedProfile
>When I call SignIn
>Then I should get Signed In successfully
>
>My idea is to make use of hooks as below, and if possible pass the
> output of @getValidatedProfiles to the 'Given' of @profilesSignin. If
> that's not possible, I can make use of a java framework to store and
> retrieve the output, but the priority is to make a scenario dependent on
> one or more other scenarios.
>
>Before('@profilesignin') do
>  //run the scenario with tag @getValidatedProfiles
>end
>
>Other than hooks, If there are any other better ways of handling
> this, please let me know.
>

I think I understand what you're after.

Hooks are not yet implemented in cucumber_java (but it would be fairly easy
to implement). If you think this
is what you need - please create a ticket in cucumber_java's github tracker.

But maybe Background is a better fit in this case?
http://wiki.github.com/aslakhellesoy/cucumber/background
It should work fine with cucumber_java.

Cheers,
Aslak


>
> Thanks,
> Neema
> --
> Posted via http://www.ruby-forum.com/.
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users