Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testes Automatizados e o iOS

Testes Automatizados e o iOS

Dicas de ferramentas e questionamentos sobre qual seria a melhor forma de testar nossas apps.
Talk rápido e enxuto feito no primeiro encontro oficial do [self SP] (http://blog.selfsp.org/?p=31)

Ricardo Valeriano

January 30, 2012
Tweet

More Decks by Ricardo Valeriano

Other Decks in Programming

Transcript

  1. é como? • É feia • Não é um talk

    extremamente técnico • Deixa isso pro @dchohfi • Mas assume que você já usa o Xcode... Monday, January 30, 12
  2. é como? • É feia • Não é um talk

    extremamente técnico • Deixa isso pro @dchohfi • Mas assume que você já usa o Xcode... Monday, January 30, 12
  3. é como? • É feia • Não é um talk

    extremamente técnico • Deixa isso pro @dchohfi • Mas assume que você já usa o Xcode... Monday, January 30, 12
  4. Teste Unitário • Testa em isolamento • Independente de interações

    • (Mocks, Stubs e relacionados) Monday, January 30, 12
  5. Opalhes :) • Roda no dispositivo (e no simulador) •

    Integrado com a IDE • É só JavaScript • Vai bem com Jasmine Monday, January 30, 12
  6. Tapping! var target = UIATarget.localTarget(); var app = target.frontMostApp(); var

    window = app.mainWindow(); var button = window.buttons()[0]; button.tap(); target.tap({x:100, y:200}); Monday, January 30, 12
  7. LogFail? LogPass? var target = UIATarget.localTarget(); UIALogger.logStart("go to original position");

    target.tap({x:100, y:200}); if (field.rect()["origin"]["y"] == position) ! UIALogger.logPass("ok"); else ! UIALogger.logFail("Nok"); Monday, January 30, 12
  8. Opalhes :) • Roda no dispositivo (e no simulador) •

    Integrado com a IDE • Objective-C Monday, January 30, 12
  9. aaaahh :( • Marcos (STAssertTrue) • Cru (nada de mocks

    ou afins) • Objective-C Monday, January 30, 12
  10. Just Code #import "RTZTranslator_tests.h" #import "RTZTranslator.h" @interface RTZTranslator_tests() { @private

    RTZTranslator *translator; } @end @implementation RTZTranslator_tests - (void)setUp { [super setUp]; translator = [[RTZTranslator alloc] init]; } Monday, January 30, 12
  11. STAssert...? - (void)testNossaToCacildis { NSString *translation = [translator translateFrom:@"nossa, nossa,

    assim..."]; BOOL isEqual = [translation isEqualToString:@"cacildis, cacildis, assim..."]; STAssertTrue(isEqual, @"nossa test"); } Monday, January 30, 12
  12. Google Toolbox for Mac • Sem .h • STAssertEqualStrings •

    STAssertNotEqualString • Keychain Testing • Testes de UI Monday, January 30, 12
  13. Google Toolbox for Mac • Sem .h • STAssertEqualStrings •

    STAssertNotEqualString • Keychain Testing • Testes de UI iPhoneUnitTesting Monday, January 30, 12
  14. GHUnit • Sem .h • GHAssertEqualStrings • GHAssertNotEqualString • Testes

    de UI • (IMHO) Bem documentado Monday, January 30, 12
  15. GHUnit • Sem .h • GHAssertEqualStrings • GHAssertNotEqualString • Testes

    de UI • (IMHO) Bem documentado Objective-C (OSX e iOS) Monday, January 30, 12
  16. Frank Feature: Login to the app Scenario: Successful login Given

    I launch the app When I log in with a valid userid and password Then I am on the start view Monday, January 30, 12
  17. Frank Cucumber Feature: Login to the app Scenario: Successful login

    Given I launch the app When I log in with a valid userid and password Then I am on the start view Monday, January 30, 12
  18. Frank When /^I use the keyboard to fill in the

    textfield marked "([^\\"]*)" with "([^\\"]*)"$/ do |text_field_mark, text_to_type| text_field_selector = "view marked:'#{text_field_mark}'" check_element_exists( text_field_selector ) touch( text_field_selector ) frankly_map( text_field_selector, 'setText:', text_to_type ) frankly_map( text_field_selector, 'endEditing:', true ) end Monday, January 30, 12
  19. Frank (setps) Ruby When /^I use the keyboard to fill

    in the textfield marked "([^\\"]*)" with "([^\\"]*)"$/ do |text_field_mark, text_to_type| text_field_selector = "view marked:'#{text_field_mark}'" check_element_exists( text_field_selector ) touch( text_field_selector ) frankly_map( text_field_selector, 'setText:', text_to_type ) frankly_map( text_field_selector, 'endEditing:', true ) end Monday, January 30, 12