2012-01-02 6 views
0

현재 Apple의 UIAutomation API를 사용하여 자바 스크립트로 작성된 여러 가지 기능 테스트가 있습니다. 테스트는 iPhone 용이지만 애플리케이션은 iPad를 지원합니다.기능 테스트가 실행중인 iOS 장비는 어떻게 검색합니까?

iPad에서 실행되도록 테스트를 연장하려면 코드에서 조정해야하지만 먼저 테스트를 실행하는 장치를 찾아야합니다.

테스트를 실행하는 장치/시뮬레이터를 어떻게 검색합니까? 자동화 도구에서 자바 스크립트 테스트를 실행하고 있습니다.

+0

파일 내 유틸리티에서 StrContains 방법에 대한 코드 당신의 코드를 작성하십시오. 그렇다면 어떻게 호출해야합니까? –

+0

인터페이스가 아마도 내가 찾고있는 인터페이스 일 것입니다. Xcode의 자동화 도구를 사용하여 Apple에서 지시 한대로 스크립트 파일을로드합니다. 내가 아는 한, 이것은 앱을 테스트하기 위해 공식적으로 지원되는 방법입니다. http://developer.apple.com/library/ios/#documentation/ToolsLanguages/Reference/UIAElementClassReference/UIAElement/UIAElement.html#//apple_ref/doc/uid/TP40009903 – MdaG

답변

1

UIATarget.localTarget(). model()에는 검사가 실행되는 장치에 대한 정보가 들어 있습니다.

나는 Alex Vollmer's tuneup_js library을 발견했습니다. 그것은 최소한 어느 정도 장치 독립 코드를 허용합니다.

예)

test("my test", function(target, app) { 
    assertWindow({ 
    "navigationBar~iphone": { 
     leftButton: { name: "Back" }, 
     rightButton: { name: "Done" } 
    }, 
    "navigationBar~ipad": { 
     leftButton: null, 
     rightButton: { name: "Cancel" } 
    }, 
    }); 
}); 

편집 tuneup_js에서 다음을 찾을 수

: 나는 장치 특정 코드를 작성 할 수 있습니다 다음으로

/** 
    * A convenience method for detecting that you're running on an iPad 
    */ 
    isDeviceiPad: function() { 
     return this.model().match(/^iPad/) !== null; 
    }, 

    /** 
    * A convenience method for detecting that you're running on an 
    * iPhone or iPod touch 
    */ 
    isDeviceiPhone: function() { 
     return this.model().match(/^iPhone/) !== null; 
    } 

.

1

여기에 제공되는 설명서에 따라, 당신은 모든 정보를 얻을 것이다 : 등등 // 여기에 장치 이름을 얻기 위해 사용하고있는 스크립트, OS 버전, 번들 ID이며, 대상 https://developer.apple.com/library/ios/#documentation/ToolsLanguages/Reference/UIATargetClassReference/UIATargetClass/UIATargetClass.html

여기
#import "tuneupjs/Utilities.js" 
var target = UIATarget.localTarget(); 

var app_bundle_id = target.frontMostApp().bundleID(); 
UIALogger.logDebug("App Bundle Id : " + app_bundle_id); 

if(app_bundle_id.strContains("ShazamDev")) 
    UIALogger.logDebug("Running UIA Scripts for ShazamDev"); 

var device_name = target.name(); 
UIALogger.logDebug("Phone Name : " + target.name()); 

var device_model = target.model(); 
UIALogger.logDebug("Device Model: " + device_model); 

//UIALogger.logDebug("System Name: " + target.systemName()); 

var ios_version = target.systemVersion(); 
UIALogger.logDebug("IOS Version: " + ios_version); 
0

는 어떤 목적 C 인터페이스가, 당신은 자바 스크립트 테스트로이 일을하는 경우

String.prototype.strContains = function(value, ignorecase) { 
    if (ignorecase) { 
     return (this.toLowerCase().indexOf(value.toString().toLowerCase()) != -1); 
    } 
    else { 
     return this.indexOf(value) != -1; 
    } 
}; 
관련 문제