mardi 22 décembre 2015

Passing data between intern test suites

I have a very large test suite edit_person_test.js that I am trying to decompose into smaller test suites. I would like to call smaller suites like add_person_cancel.js from a main suite and pass data created in the main suite's before() into the smaller test suites (edit_person_test.js line 75). However when I try and access the data in the smaller test suite it is still null. How can I create one copy of the data and pass it into every smaller test suite?

// Very large parent suite add_person_test.js
define([
  'intern!object',
  'pages/PersonTabPage',
  'pages/AddPersonPage',
  'data-objects/PersonData',
  './add_person_cancel'
], function(registerSuite, PersonTabPage, AddPersonPage, Person, addPersonCancel) {

registerSuite(function() {

  var personTabPage = null;
  var addPersonPage = null;
  var person = null;

  return {
    // Assumes we are logged in
    name: 'Edit Person Test',

    before: function() {
      person = new Person(); // randomly generated data to create person with
      personTabPage = new PersonTabPage(this.remote, this.timeout);
      addPersonPage = new AddPersonPage(this.remote, this.timeout);
    },

    // calling smaller suite here
    AddPersonCancel: addPersonCancel.CancelAddPersonTest(personTabPage, addPersonPage, person),

  };
});
});


// Smaller test suite add_person_cancel.js
define(function() {

  return function(personTabPage, addPersonPage, person) {
    return {
      // Assumes we are logged in
      name: 'Cancel Add Person Test',

      OpenAddPersonPage: function() {
        logger.info(person);
        return personTabPage.clickAddPerson()
          .getAccumulatedState();
      },

      ValidateButtonDisabledStatus: function() {
        return addPersonPage.personButtonStatus(function(status) {
            assert.isFalse(status, 'Buttons are enabled even before entering person name');
          })
          .getAccumulatedState();
      },

      EnterNameClickCancelButton: function() {
        return addPersonPage.enterFirstName(person.firstName)
          .enterLastName(person.lastName)
          .clickCancelButton()
          .waitForPageReady()
          .getAccumulatedState();
      },

      CheckPersonNameNotSaved: function() {
        return personTabPage
          .findInPersonsTableAssertion(person.firstName + ' ' + person.lastName, false, function(result) {
            assert.isFalse(result, 'Person name is saved even on closing the trowser using Cancel button');
          })
          .getAccumulatedState();
      }
    };
  };
});

Aucun commentaire:

Enregistrer un commentaire