Top Banner
Unit Tests Aren’t Enough and your QA guy can’t regression test for you...
33

Unit Tests Arent Enough

Jan 29, 2018

Download

Technology

Trotter Cashion
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Unit Tests Arent Enough

Unit Tests Aren’t Enoughand your QA guy can’t regression test for you...

Page 2: Unit Tests Arent Enough

Will this test save you?

def test_create_new_widget post :create_widget assert_response :successend

Page 3: Unit Tests Arent Enough

With this code?

# view:<%= form_for :widget %> <%= submit_tag “Create” %><% end %>

# controller:def create; puts “doing nothing”; end

Page 4: Unit Tests Arent Enough

The Individual Pieces Work...

Page 5: Unit Tests Arent Enough

... but your application does not!

Page 6: Unit Tests Arent Enough

What do we do?

Page 7: Unit Tests Arent Enough

QA Guy!

Page 8: Unit Tests Arent Enough

Benefits

Page 9: Unit Tests Arent Enough

Would he find the bug from before?

Page 10: Unit Tests Arent Enough

What if the bug came from a refactoring?

Page 11: Unit Tests Arent Enough

YOU are ultimately responsible for your app

Page 12: Unit Tests Arent Enough

Let’s Automate

Page 13: Unit Tests Arent Enough

Hello, Selenium!

Page 14: Unit Tests Arent Enough

The Code

Page 15: Unit Tests Arent Enough

The API

Page 16: Unit Tests Arent Enough

Programmers still do the testing!

Page 17: Unit Tests Arent Enough

Hello, Cucumber!

Page 18: Unit Tests Arent Enough

QA Can Write This

Scenario: Searching on Google Given I am on the homepage When I fill in “q” with “cukes” And I press “Google Search” Then I should see “cukes.info”

Page 19: Unit Tests Arent Enough

Scenario: Searching on Google

Page 20: Unit Tests Arent Enough

Given I am on the homepage

Page 21: Unit Tests Arent Enough

When I fill in “q” with “cukes”

Page 22: Unit Tests Arent Enough

And I press “Google Search”

Page 23: Unit Tests Arent Enough

Then I should see “cukes.info”

Page 24: Unit Tests Arent Enough

The Output

Scenario: Searching on Google # features/google_search.feature:6 Given I am on the homepage # features/step_definitions/webrat_steps.rb:6 When I fill in "q" with "cukes" # features/step_definitions/webrat_steps.rb:29 And I press "Google Search" # features/step_definitions/webrat_steps.rb:17 Then I should see "cukes.info" # features/step_definitions/webrat_steps.rb:121

1 scenario (1 passed)4 steps (4 passed)0m10.206s

Page 25: Unit Tests Arent Enough

Webrathttp://gitrdoc.com/brynary/webrat/tree/master

Page 26: Unit Tests Arent Enough

Webrat Caveats

• Won’t detect elements hidden by a class

• Won’t click things that aren’t links or buttons (usually not a big deal)

Page 27: Unit Tests Arent Enough

Beyond Webrat

When /^I search for “([^”])”$/ do |s| When %Q|I fill in “q” with “#{s}”| And %Q|I press “Google Search”|end

Page 28: Unit Tests Arent Enough

Cucumber Structure

features/*.featurefeatures/step_definitions/*_steps.rbfeatures/support/*.rb

Page 29: Unit Tests Arent Enough

Cuke-Talkerhttp://github.com/trotter/cuke-talker

Page 30: Unit Tests Arent Enough
Page 31: Unit Tests Arent Enough

Commands

• Given, When, Then, And

• !

• define step

• run feature

• show history

• show step definitions

Page 32: Unit Tests Arent Enough

Resources

• http://cukes.info

• http://gitrdoc.com/brynary/webrat/tree/master

• http://github.com/trotter/cuke-talker