Em primeiro lugar, teste seu projeto. Depois aprenda como NÃO testá-lo. Palestra cheia de exemplos de testes que hoje em dia não escrevemos mais, para nos lembrar dos testes que temos continuar automatizando. Dev Day 2014
2. @freire_da_silva
• Director of Product Safety @IndustrialLogic
• Agil desde 2001, lean desde a 1ª série
• Founder: AgilCoop, AgilBits e ).(
• Mestrado na USP:
“Reflexões sobre
o Ensino de Metodologias Ágeis
na Academia, Indústria e Governo”
• Gosto de nadar e construir casas
• Experiência e alex@industriallogic.com sucesso com muitos amigos:
73. @martinfowler
you’re doing enough testing if the
following is true:
■You rarely get bugs that escape
into production
■You are rarely hesitant to change
some code for fear it will cause
production bugs
74. @joshuakerievsky Test first/after misses the point that
TDD is more about emergent design
than it is about testing. Do you
practice emergent design?
75. @kentbeck If I don’t typically make a mistake(...),
I don’t test for it.
!
Wish there were more examples of
“what not to test and how not to
test”.
76.
77. 2def create_name(fname,
lname):
3 if not isInstance(fname,
basestring):
4 raise TypeError(“fname
must be a String”)
5 if not isInstance(lname,
basestring):
6 raise TypeError(“lname
must be a String”)
7 name = fname + lname
78. 1 require ‘spec_helper‘
2 describe Candidate do
3 context ‘associations‘ do
4 it { should have_many(:proposals) }
5 end
6
7 context ‘validations‘ do
8 it { should validate_presence_of :name }
9
10 it { should ensure_lenght_of(:phone).
11 is_at_least(7).
12 is_at_most(14)
13 }
14
15 it { should_not
16 allow_value(‘blah‘).for(:site) }
17
18 it { should
19 allow_value(‘http://www.blah.com‘)
20 .for(:site) }
21 end
22end
80. 1 require ‘spec_helper‘
2 describe Candidates do
3
4 let(:candidate) {double ‘candidate‘}
5
6 before :each do
7 Candidate
8 .should_receive(:find)
9 .with(1).and_return(candidate)
10 end
11
12 it ‘should find the candidate‘ do
13 c = Candidate.find(1)
14 c.should eql candidate
15 end
16end
81. 1Feature: Create proposal
2 As a candidate
3 I want to post my proposals
4 So that voters can evaluate them
5
6 Scenario:
7 Given I am logged in
8 And I am posting a proposal
9 When
10 I fill all fields of the proposal
11 Then
12 I should see a success message
82. 1Scenario: Client sees tooltip for plan
2 Given
3 I select the ‘light‘ plan
4 When
5 I mouse over ‘tooltip‘
6 Then
7 I should see ‘tooltip‘ content
8 And
9 I mouse out ‘tooltip‘
10 Then
11 I should not see ‘tooltip‘ content
83. 1require ‘spec_helper‘
2describe ShoppingCart do
3
4 let(:user) {double ‘user‘}
5 let(:product) {double ‘product‘}
6
7 before :each do
8 Authenticator.should_receive(:auth)
9 .and_return(true)
10 end
11
12 it ‘should addProduct & getTotal‘ do
13 Authenticator.auth(user)
14 cart = ShoppingCart.new
15 cart.add_product(product)
16 cart.get_total
17 end
18end
89. 1 require ‘spec_helper‘
2 describe AddressController do
3
4 it ‘should calculate shipping‘ do
5 get :shipping, :zipcode => ‘90210‘
6 assigns(:shipping).should == ‘8.2‘
7 end
8
9 end
97. it(‘centers logo at top of page’, function() {
expect(isConTenteCenteredInPage(logo)).toBe(true);
expect(elementPicelsFromTopOfPage(logo)).toBe(12);
expect(fontSizeOf(logo)).toBe(22);
expect(textColorOf(logo)).toBe(WHITE);
});