Currently, in my Google Apps Script project, I am unit-testing an application using QUnit for test-driven development purposes.
Code Under Test
The function I am currently focusing on testing and developing is the creation of a Sheet from a long string of data:
/**
*
* Creates a Sheet from a long string of datadata
* @param { string } data : the long string of data
* @returns { Sheet } the newly-created Sheet
**/
function createSheetFrom(data) {
// code logic here
}
This function relies on another function called createTitleRow
, which has already been fully tested and developed successfully.
Testing Process
As part of my testing process, I have created tests for both createSheetFrom
and createTitleRow
. Both sets of tests are passing successfully. However, when I added a sanity test to mock out createTitleRow
in the setup, only to revert it back to its original form in the teardown, both sets of tests started failing.
I am experiencing regressions in my tests even though I am attempting to restore the objects' states back to their original form after each test. The changes made in one test seem to be carrying over to other tests as well, leading to unexpected failures.