Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于JavaScript的Bitbar Cloud Appium服务器端测试包内容_Javascript_Appium_Server Side_Bitbar - Fatal编程技术网

用于JavaScript的Bitbar Cloud Appium服务器端测试包内容

用于JavaScript的Bitbar Cloud Appium服务器端测试包内容,javascript,appium,server-side,bitbar,Javascript,Appium,Server Side,Bitbar,有人知道当使用Javascript作为语言时,用于服务器端测试运行的zip文件的内容应该是什么吗?我已经在github页面()上查看了python和ruby示例,但是Javascript没有任何内容,java和python也是如此。但是Javascript没有任何内容。来自文档: 测试所需的所有文件都需要作为zip包上传到云。此包必须包含测试文件、数据文件,并且需要有一个Shell脚本来在包的根级别启动测试执行 以及: 为了让云端执行正常工作,让测试套件zip配备正确的文件是很重要的。在这里,我

有人知道当使用Javascript作为语言时,用于服务器端测试运行的zip文件的内容应该是什么吗?我已经在github页面()上查看了python和ruby示例,但是Javascript没有任何内容,java和python也是如此。但是Javascript没有任何内容。

来自文档:

测试所需的所有文件都需要作为zip包上传到云。此包必须包含测试文件、数据文件,并且需要有一个Shell脚本来在包的根级别启动测试执行

以及:

为了让云端执行正常工作,让测试套件zip配备正确的文件是很重要的。在这里,我们将浏览这些文件以及测试zip的正确组成。最重要的是runtests.sh文件,它负责在云中启动测试执行并安装需求

因此,理论上,您只能在ZIP包中运行tests.sh文件。因为这是一个简单的bash脚本,所以您可以自由使用该脚本。查看Python和Ruby示例,我的ZIP结构就是这样的:

.
├── package.json
├── package-lock.json
├── run-tests.sh
├── test
│   └── specs
│       └── main.js
└── wdio.conf.js
我使用了-这就是为什么我使用了
wdio.conf.js
test/specs/main.js

这就是我的
运行tests.sh的样子:

#!/usr/bin/env bash

echo "Preparing..."

# Make sure there's no pre-existing `screenshots` file blocking symbolic link creation
rm -rf screenshots

# Recreate screenshots dir
mkdir screenshots

echo "Extracting tests.zip..."
unzip tests.zip

echo "Installing dependencies..."
npm install

echo "Running tests..."
./node_modules/.bin/wdio wdio.conf.js
我的
main.js
(我使用了
bitbar示例app.apk
和从顶部开始的测试方法):

以及
wdio.conf.js
(查看
之前的
):

最后,但并非最不重要的
package.json

{
  "name": "appium-server-side-example",
  "version": "1.0.0",
  "description": "Bitbar Cloud Appium Server Side Test Example",
  "author": "Marek Sierociński <marek.sierocinski@smartbear.com>",
  "license": "ISC",
  "dependencies": {
    "@wdio/appium-service": "^5.16.5",
    "@wdio/cli": "^5.16.7",
    "@wdio/junit-reporter": "^5.15.5",
    "@wdio/local-runner": "^5.16.7",
    "@wdio/mocha-framework": "^5.16.5",
    "@wdio/spec-reporter": "^5.16.5",
    "@wdio/sync": "^5.16.5",
    "chai": "^4.2.0"
  }
}
{
“名称”:“appium服务器端示例”,
“版本”:“1.0.0”,
“说明”:“Bitbar Cloud Appium服务器端测试示例”,
“作者”:“Marek Sierociński”,
“许可证”:“ISC”,
“依赖项”:{
“@wdio/appium服务”:“^5.16.5”,
“@wdio/cli”:“^5.16.7”,
“@wdio/junit reporter”:“^5.15.5”,
“@wdio/local runner”:“^5.16.7”,
“@wdio/mocha framework”:“^5.16.5”,
“@wdio/spec reporter”:“^5.16.5”,
“@wdio/sync”:“^5.16.5”,
“chai”:“^4.2.0”
}
}
正如您所见,我使用了
chai
(因为我想使用BDD方法)和(因为Bitbar开发者是Java怪胎,您可以从示例中猜到Cloud正在读取JUnit文件以读取测试方法)

这对我有用:

const path = require('path');

exports.config = {
    runner: 'local',

    framework: 'mocha',
    mochaOpts: {
        ui: 'bdd',
        timeout: 60000
    },

    logLevel: 'silent',
    deprecationWarnings: true,

    bail: 0,
    waitforTimeout: 10000,
    connectionRetryTimeout: 90000,
    connectionRetryCount: 3,

    reporters: [
        'spec',
        [
            'junit', {
                outputDir: './',
                outputFileFormat: () => {
                    return 'TEST-all.xml';
                }
            }
        ]
    ],

    host: '127.0.0.1',
    port: 4723,
    path:  '/wd/hub',

    services: ['appium'],
    appium: {
        command: 'appium',
        logPath : './',
    },

    specs: [
        './test/specs/**/*.js'
    ],

    capabilities: [{
        platformName: 'Android',
        maxInstances: 1,

        'appium:deviceName': 'Android device',
        'appium:automationName': 'UiAutomator2',
        'appium:app': path.resolve('application.apk'),
        'appium:appActivity': '.BitbarSampleApplicationActivity',
        'appium:appPackage': 'com.bitbar.testdroid',
        'appium:newCommandTimeout': 240
    }],

    before: function() {
        const chai = require('chai');
        global.expect = chai.expect;
        chai.should();

        const fs = require('fs');

        global.takeScreenshot = async (fileName) => {
            let screenshot = await driver.takeScreenshot();
            screenshot = screenshot.replace(/^data:image\/png;base64,/, "")
            let filePath = path.resolve(`./screenshots/${fileName}.png`);
            fs.writeFileSync(filePath, screenshot, 'base64');
        };

    }
}
{
  "name": "appium-server-side-example",
  "version": "1.0.0",
  "description": "Bitbar Cloud Appium Server Side Test Example",
  "author": "Marek Sierociński <marek.sierocinski@smartbear.com>",
  "license": "ISC",
  "dependencies": {
    "@wdio/appium-service": "^5.16.5",
    "@wdio/cli": "^5.16.7",
    "@wdio/junit-reporter": "^5.15.5",
    "@wdio/local-runner": "^5.16.7",
    "@wdio/mocha-framework": "^5.16.5",
    "@wdio/spec-reporter": "^5.16.5",
    "@wdio/sync": "^5.16.5",
    "chai": "^4.2.0"
  }
}