astropanic
astropanic

Reputation: 10939

ruby cucumber testing practices

I have many cucumber feature files, each consists of many scenarios.

When run together, some of them fails. When I run each single test file, they passes. I think my database is not correctly clean after each scenario.

What is the correct process to determine what is causing this behavior ?

Upvotes: 0

Views: 268

Answers (2)

Josh Crews
Josh Crews

Reputation: 799

This happens to me for different reasons and different times.

Sometimes its that a stub or mock is invoked in one scenario that screws up another, but only when they are both run (each is fine alone).

The only way I've been able to solve these is debugging while running enough tests to get a failure. You can drop the debugger line in step_definitions or call it as a step itself (When I call the debugger) and match that up to a step definition that just says 'debugger' as the ruby code.

Upvotes: 0

lambsubstitute
lambsubstitute

Reputation: 1991

By the sound of it your tests are depening upon one another. You should be trying to get each indervidual test to do what ever set up is required for that indervidual test to run.

The set up parts should be done during the "Given" part of your features. Personally, to stop the features from becoming verbose and to keep them close to the business language that they where written in, i sometimes add additional steps that are required to do the setup and call them from the steps that are in the feature file. If this makes sence to you

Upvotes: 2

Related Questions