运行量角器测试后将报表保存到数据库中

whlutmcx  于 2021-06-19  发布在  Mysql
关注(0)|答案(1)|浏览(468)

我是角量角器测试的新手。我创建了一些测试用例,基于jasminerunner-bdd风格的量角器框架。在一个测试类中,我有10到12个规范,每个规范都有一个期望值。但现在我计划将这个测试用例保存到数据库中。例如,为测试创建表,该列应包括测试编号、测试名称、规格、失败或通过等。
我在用密码解释。
这是一个有10个规格的单一类

describe('03 check all user report settings', function () {

// 1.
it('login to page', async () => {
    await loginIntoPage(url, username, password);
    await expect(notification.isDisplayed());
});

// 2.
it('Navigate to user page', async () => {
    await button.click(userPage);
    await expect(pageTitleUserPage.getText()).toBe('User');
});

// 3.
it('click onto active button', async () => {
    await button.click(activeButton);
    await expect(notification.isDisplayed());

});

// 4.
it('daily option is selected', async () => {
    await button.click(dailyOption);
    await expect(dailyOption.isEnabled).toBeTruthy();
});

// 5.
it('Report generation is selected', async () => {
    await button.click(reportGeneration);
    await expect(reportGeneration.isEnabled).toBeTruthy();
});

// 6.
it('report language is selected', async function () {
    await button.click(languageDropdown);
    await languageDropdown.isDisplayed();
});

// 7.
it('English is selected', async function () {
    await button.click(english);
    await expect(languageDropdown.getText()).toContain('English');
});

// 8.
it('Time period is displayed', async function () {
    await button.click(timePeriod)
    await timePeriod.isDisplayed();
});

// 9.
it('an hour is selected', async function () {
    await button.click(hour)
    await timePeriod.isDisplayed();
});

// 10.
it('Save all edit is displayed', async function () {
    await button.click(save);
    await expect(notification.isDisplayed()).toBe(true);
  });

})

报告输出如下

Started

Executing 10 defined specs...

Test Suites & Specs:

1. 03 check all user report settings
   √ login to page (12291ms)
   √ Navigate to user page (743ms)
   √ click onto active button (464ms)
   √ daily option is selected (505ms)
   √ Report generation is selected (513ms)
   √ report language is selected (543ms)
   √ English is selected (478ms)
   √ Time period is displayed (464ms)
   √ an hour is selected (418ms)
   √ Save all edit is displayed (1162ms)

10 specs, 0 failures
Finished in 17.6 seconds

>> Done!

Summary:

Suites:  1 of 1
Specs:   10 of 10
Expects: 5 (0 failures)
Finished in 17.6 seconds

[11:01:35] I/launcher - 0 instance(s) of WebDriver still running
[11:01:35] I/launcher - chrome #01 passed

我的配置文件是

var SpecReporter = require('jasmine-spec-reporter');
const JasmineConsoleReporter = require('jasmine-console-reporter');
const reporter = new JasmineConsoleReporter({
    colors: 1,           // (0|false)|(1|true)|2
    cleanStack: 1,       // (0|false)|(1|true)|2|3
    verbosity: 4,        // (0|false)|1|2|(3|true)|4|Object
    listStyle: 'indent', // "flat"|"indent"
    timeUnit: 'ms',      // "ms"|"ns"|"s"
    timeThreshold: { ok: 500, warn: 1000, ouch: 3000 }, // Object|Number
    activity: false,     // boolean or string ("dots"|"star"|"flip"|"bouncingBar"|...)
    emoji: true,
    beep: true
});

exports.config = {
    allScriptsTimeout: 110000000,
    specs: [
        '...**/03*.e2e-spec.ts',
    ],
    multiCapabilities: [ {
        'browserName': 'chrome',
        'chromeOptions': { 'args' : ['--disable-extensions']},
        'shardTestFiles': true,
        'maxInstances': 1
    }
    ],
    seleniumAddress: 'http://...:14444/wd/hub',
    baseUrl: .........,
    framework: 'jasmine',
    jasmineNodeOpts: {
        isVerbose: true,
        showColors: true,
        defaultTimeoutInterval: 50000000

    },
    useAllAngular2AppRoots: true,
    beforeLaunch: function() {

    },
    onPrepare: function() {

        require('ts-node').register({
            project: 'e2e'
        });

        jasmine.getEnv().addReporter(reporter);
    }
};

现在我的问题是,使用表将此报表存储到数据库中的最佳方法是什么。我以前对此一无所知。

zsbz8rwp

zsbz8rwp1#

将测试结果或测试本身存储在db中的想法是不好的。
关于测试结果,有很多解决方法。
特别是量角器和茉莉我建议:诱惑2。。但是jasmine诱惑2的定制实现-jasmine
报告门户不是一个坏主意,但你必须重新编写你的自定义插件茉莉花。目前该项目支持javascript/typescript的糟糕实现。
这样,您就有了表示测试结果的文件,易于存储/移动并用于度量分析。
更多报告工具:
量角器美丽记者
茉莉花2-记者

相关问题