Skip to content

Testing procedures calling helper functions or other procedures #11

@tomfidos

Description

@tomfidos

Hi,

I try to test a quite long procedure onClick, see below, (I mean here a procedure as understood in JS: returning nothing, just writing calculation results out into a Google sheet) that consists of many other sub-procedures or functions.

Whereas testing a single function (a function as understood in JS: returning something; some of these functions don't take an input) or procedure (some of them take an input) all works fine and according to instructions from: http://qunitgs2.com/.

However tests for that long procedure (using successfully tested single functions/procedures) don't work: after depolying the test code as a web app and clicking latest code (everything exactly as by previously described code tests) a html tab pops out with a proper header, etc, but no tests run. What is more the test code doesn't call the tested procedure at all. However, it was calling tested single functions/procedures; they run and changed the sheet they worked on. Moreover, they don't need to be included in assert object.

Does it mean that it's impossible to test such procedures: being a set of other functions or procedures? Or is it something else?

Here the test suit:

let QUnit = QUnitGS2.QUnit;

function doGet() {
   QUnitGS2.init();

   QUnit.module('Script test');

   QUnit.test('onClick function', function(assert) {
       //when
       onClick();  // At the end it writes a figure in a sheet's G11 cell. 
       //then
       assert.equal(mainSheet.getRange('G11').getValue(), '2.10970231', 'provides correct total balance after running script');
   });

   QUnit.start();
   return QUnitGS2.getHtml();
}

function getResultsFromServer() {
   return QUnitGS2.getResultsFromServer();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions