【问题标题】:tuneup.js reports "Can't find variable" for test() methodtuneup.js 报告 test() 方法的“找不到变量”
【发布时间】:2013-03-08 23:14:59
【问题描述】:

enter code here因为我无法让通过/失败日志记录与 4.6 版本的 Instruments 一起正常工作,所以我正在尝试使用 tuneup.js 库,但每当我尝试运行时,我都会收到以下错误测试:

Can't find variable: test

代码如下:

//We want to use the tuneup library to add extra capabilities
#import <tuneup_js/tuneup.js>
#import <tuneup_js/test.js>

var target = UIATarget.localTarget();

var target = UIATarget.localTarget();
var app = UIATarget.localTarget().frontMostApp();

test("Test1", function(target, app) {

//Do UI automation stuff

var titleDisplayed = tableView.cells()[0].name();
var StoryName = "My Dogs!";

UIALogger.logMessage("My Story Title: " + titleDisplayed);
UIALogger.logMessage("Innocuous Message-1.");


assertEquals(titleDisplayed, StoryName); 

}); // <------Error points to this line!

//End test

知道我做错了什么吗? tuneup.js 库位于名为 tuneup_js 的文件夹中,该文件夹位于包含我的测试脚本(一个 Instruments 跟踪文件)的目录的根目录中,并且在启动时我没有收到任何导入错误。

【问题讨论】:

    标签: xcode instruments ios-ui-automation


    【解决方案1】:

    问题是 Instruments 找不到 *tuneup_js* 库,所以它找不到 test 函数。您需要在引号中添加导入并且不需要添加 tuneup_js/test.js 因为tuneup_js/tuneup.js 包含所有需要的类

    //We want to use the tuneup library to add extra capabilities
    #import "tuneup_js/tuneup.js"
    
    
    var target = UIATarget.localTarget();
    
    var target = UIATarget.localTarget();
    var app = UIATarget.localTarget().frontMostApp();
    
    test("Test1", function(target, app) {
    
    //Do UI automation stuff
    
    var titleDisplayed = tableView.cells()[0].name();
    var StoryName = "My Dogs!";
    
    UIALogger.logMessage("My Story Title: " + titleDisplayed);
    UIALogger.logMessage("Innocuous Message-1.");
    
    
    assertEquals(titleDisplayed, StoryName); 
    
    });
    

    【讨论】:

    • 非常感谢您的反馈!但是当我使用引号时,我得到一个“找不到导入文件”错误。这就是我使用 符号的原因。当我使用 时,没有导入错误。我用的是 Xcode 4.6,你也在用 4.6 吗?
    • 是的,我也在使用 4.6。您需要使用引号来导入文件,确保路径对 tuneup_js 文件正确。我觉得应该是 tuneup/tuneup.js
    • 我还想补充一点,对于那些试图链式测试多个测试(例如 test1.js、test2.js、test3.js ...)的人,请将 #import "tuneup/tuneup. js”在您的 Queue javascript 文件中,而不是单个文件(Instruments 不太擅长解析#imports)。例如,假设我有执行 #import test1.js ....test50.js 的 queue.js,我应该先将 #import "tuneup/tuneup.js" 放在我的队列中 #import test1.js 之前。 .js 文件。希望这是有道理的。
    猜你喜欢
    • 2017-03-06
    • 2013-03-01
    • 1970-01-01
    • 2018-04-27
    • 1970-01-01
    • 2021-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多