Skip to content

Instantly share code, notes, and snippets.

@piecyk
Created June 18, 2014 11:45
Show Gist options
  • Select an option

  • Save piecyk/0ae5a7b1b8623b9b43f5 to your computer and use it in GitHub Desktop.

Select an option

Save piecyk/0ae5a7b1b8623b9b43f5 to your computer and use it in GitHub Desktop.

sTest - stability and performance lib

this is simple small module to run stability tests, the idea is easy, it takes steps in the test in a loop base on how long you tel "him" to run... for example 20s || 1h and save te results of mem usage browser, cup usage browser and time how long it take, you can have many test case this in one test suite:

  • gruntjs
  • protractorjs
  • mochajs
  • chaijs
  • selenium standalone server

Before running tests:

  • cd sTest
  • npm install
  • edit Gruntfile.js
  • check params in firefox task
  • check selniumStart
    • selenium jar and diver path, set it to where you download the selenium
  • express server to see resutls
  • edit protractor.conf.js
  • to change login method

tasks with args

  • grunt test // start test's'(it runs: grunt seleniumStart && grunt protractor:firefox && grunt seleniumStop)
    • --unite=h // how long tests will go you can seconds/minutes/hours
    • --time=1 // how long int
    • --user=admin // user login name
    • --pass=changeme // user pass
    • --baseUrl="http://refresh.efecte.com/efecte" // url
    • --reportDir="/reportJenkis" // where the statistic will be saved
    • --spec="onLoop" // specific one test case to run
    • --reporter="xunit-file" // it will save a xunit.xml file for jenkis
  • grunt seleniumStart // starts selenium server
  • grunt seleniumStop // stops selenium server
  • grunt protractor:firefox // starts test
  • grunt stats // starts server wit stats

example for jenkis:

grunt test --unite=s --time=30 --user=demo --baseUrl="http://refresh.efecte.com/efecte" --reporter="xunit-file"

folder list:

  • Gruntfile.js // config for grunt
  • README.md // this readme
  • lib
    • 2.42.2 // for example where to put selenium jar
    • README.md // readme from where to download
  • node_modules // where npm install goes
  • package.json // package file with version
  • protractor.loop.conf.js // config file
  • report // where the statistic goes
  • stats-server.js // server config for statistic
  • tasks // folder with task for grunt
  • test // folders with tests
    • onLoop.spec.js // simple test case
    • helpers // helpers functions files
      • helpers.js // helpers to run tests in loop and write
      • pageObj.js // pageObj started refactor of commonPageObj after change to protractor v0.24.0
      • commonPageObj.js // old page obj for efecte refresh
  • xunit.xml // results for jenkis

simple loop test

var ptor = protractor.getInstance();
var chai = require('chai').use(require('chai-as-promised'));
var Helpers = require('./helpers/helpers');
var PageObj = require('./helpers/pageObj');

describe('loop test', function(){
  var expect = chai.expect;
  it('loop tests', function() {
    // if multi loop test in one file you can change this for each test case 
    //browser.paras.cfg.time.unite = 's';
    //browser.paras.cfg.time.value = '20';
    
    var helpers = new Helpers(browser.params);    
    var flow = protractor.promise.controlFlow();    
    var page = new PageObj(browser.params, flow, expect);
    // this will go to url one time
    page.goToUrl();
    
    // this will run for 20s
    helpers.flowFn(flow, null, new Date().getTime(), function(obj, time) {
      //http://refresh.efecte.com/
      page.setGlobalSearchInput('Julie')
          .makeGlobalSearch()     
          .checkTheNumberOfResultInListView(16);
    });
  });
});

TODO:

  • chrome support
  • auto download selenium jar and drivers

links

know errors:

firefox:

-https://code.google.com/p/selenium/issues/detail?id=3280

##configure linux machine:

run the xvfb and export and grunt stats as a script on startup the server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment