{"id":13433766,"url":"https://github.com/techstreams/Apps-Script-TestApp-Library","last_synced_at":"2025-03-17T13:30:50.470Z","repository":{"id":84568127,"uuid":"50604088","full_name":"techstreams/Apps-Script-TestApp-Library","owner":"techstreams","description":"Small Apps Script service to add unit testing to your project","archived":false,"fork":true,"pushed_at":"2016-01-28T19:12:16.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-28T16:13:43.606Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Spencer-Easton/Apps-Script-TestApp-Library","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techstreams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-28T18:33:15.000Z","updated_at":"2022-10-03T08:22:49.000Z","dependencies_parsed_at":"2023-04-22T16:15:42.356Z","dependency_job_id":null,"html_url":"https://github.com/techstreams/Apps-Script-TestApp-Library","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techstreams%2FApps-Script-TestApp-Library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techstreams%2FApps-Script-TestApp-Library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techstreams%2FApps-Script-TestApp-Library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techstreams%2FApps-Script-TestApp-Library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techstreams","download_url":"https://codeload.github.com/techstreams/Apps-Script-TestApp-Library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244041387,"owners_count":20388229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T02:01:35.592Z","updated_at":"2025-03-17T13:30:50.133Z","avatar_url":"https://github.com/techstreams.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Apps-Script-TestApp-Library\nTestApp is a service for unit testing in Google Apps Script.  \nIt can be added with the key `Mm17sZ23ccjNtfj2PvKV798h00DPSBbB3` or from the source in the src folder.  \n\n#### Using TestApp  \n#####Build the Test Configuration Object for TestApp.  \n######You can use either method:  \n\n1) Build the object manually.  \nThe test config object is a object following the convention:  \n`{\"functionName\":{params:[array of params],returnVal:\"the expected return value\"}, ...}`  \nExample test object:  \n  \n    var testObject = \n        {\n          \"addOne\":{params:[1],returnVal:2},\n          \"subtract\":{params:[20,10],returnVal:10},\n          \"removeChar\":{params:[\"mississippi\",\"i\"],returnVal:\"msssspp\"},\n          \"notTrue\":{params:[true],returnVal:false}\n        };\n\n2) Use the TestBuilder service in TestApp.  \n\n    var testObject = TestApp.TestBuilder();\n    testObject.addFunction(\"addOne\",[1],2)  \n              .addFunction(\"subtract\",[20,10],10)\n              .addFunction(\"removeChar\",[\"mississippi\",\"i\"],\"msssspp\")\n              .addFunction(\"notTrue\",[true],false);\n    testObject.TestObject(); // returns the test config object  \n      \n##### Using TestRunner to run your tests  \nTo use the TestRunner service you need to create a new TestRunner object passing it the `this` scope you are testing in. Typical case would be the Global Object `this`, but you can pass the `this` of any scope you are testing in.  If you need a reminder of `this` scoping look in the example directory for `ThisScopeExamples.gs`. Then you can use the `RunTest(TestConfigObject, callback)`.  \nExample:  \n\n    function runTests(){\n     var testObject = TestApp.TestBuilder();\n     testObject.addFunction(\"addOne\",[1],2)  \n               .addFunction(\"subtract\",[20,10],10)\n               .addFunction(\"removeChar\",[\"mississippi\",\"i\"],\"msssspp\")\n               .addFunction(\"notTrue\",[true],false);\n        \n      //When runTests() is invoked by the Apps Script service it's 'this' is the Global Object.\n      var tr = new TestApp.TestRunner(this);  \n      tr.RunTest(testObject.TestObject(),checkResults);\n    }  \n\n##### Handling the RunTest callback  \nThe callback will recieve a TestResults object as its first paramater.  \nThe TestResults object has two methods. `getResults` will return the results as an array. `toString` will return the results as a string.  The results array follows the following convention:  \n`[{name:\"functionName\",status:\"PASSED/FAILED\" [,error:\"error message\"]} , ... ]`  \n  \nThe following example callback writes the sorted results to the Logger service,  with some [imagination](http://vignette2.wikia.nocookie.net/spongebob/images/9/9d/Spongebob_Imagination_by_kssael.png/revision/latest?cb=20120225122618)  you can respond to the tests with emails, github updates, badges, banners?, etc.  \n  \n      function checkResults(testLog){\n        Logger.log(\"TESTS FAILED:\");\n        for(var test in testLog.getResults()){\n          if(testLog.getResults()[test].status == \"FAILED\"){\n            Logger.log(testLog.getResults()[test].name +\" : \"+testLog.getResults()[test].error );    \n          }\n        }\n       Logger.log(\"TESTS PASSED:\");\n       for(var test in testLog.getResults()){      \n        if(testLog.getResults()[test].status == \"PASSED\"){\n          Logger.log(testLog.getResults()[test].name);    \n        }  \n       }   \n     }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechstreams%2FApps-Script-TestApp-Library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechstreams%2FApps-Script-TestApp-Library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechstreams%2FApps-Script-TestApp-Library/lists"}