TechoTek
TechoTek

Reputation: 43

Save report into database after running a protractor test

I am very new in angular protractor testing. I create some test cases, based on protractor framework with jasmine runner BDD style. In one single test class I have 10 to 12 specs with one expectation for each spec. Now, I am running this test in selenium server directly. But Now I am planing to save this test case into database. For example creating table for tests, which column should include Test number, Test name, specs, failure or passed etc.

I am explaining with code.

This is one single class with 10 specs

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);
  });

})

the report output is as follows

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

My Config file is

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);
    }
};

Now my question is what is the best way to store this report into database using table. I have no previous idea about this.

Upvotes: 1

Views: 825

Answers (1)

Infern0
Infern0

Reputation: 2814

the idea to store test-results or tests itself in db its BAD.

About the test results, there is many solutions.

Specifically for protractor and jasmine i would suggest: Allure2 .. but the custom implementation for jasmine Allure 2 - jasmine

Report-portal its not a bad idea also but you have to re-write your custom plugin for jasmine. Currently the project supports poor implementation for javascript/typescript.

Like this you have files representing the test results, easy to store/move and be used for metrics analysis.

More tools for reporting tools:

Upvotes: 1

Related Questions