Wednesday, 18 May 2022

CFML: Filler article with code but no TDD at all


I'm still working on the TinyTestFramework though: some things don't change.

My test file for this work, which is the framework and all its tests in one is getting a bit weighty: >1200 LOC, and I'm fiding it difficult to navigate about the place. Especially as I'm using as my dev environment :-).

Using the technique I recently documented to execute code on remotely ("Running CFML code on via a remote HTTP request"), I've split-out the framework and the tests into different gists, and wrote a wee calling-harness to run them all… and for completeness on both ColdFusion 2021 and Lucee 5.

This way I can just have the new tests I am working on in front of me, and have all the rest of the tests running in a different window.

It's not doing anything complicated: just some loops and some HTTP requests to get the code from GitHub, and send it to; and then outputing the response:

    method = "get",
    url = "",
    result = "frameworkCodeResponse",
    throwOnError = true
frameworkCode = frameworkCodeResponse.fileContent;

testSuites = [
    "Tests for misc functions that don't fit another category" = {
        guid = "332e3cda31fa933cfe3a783be07bc59e",
        file = "ttfOtherFunctionsTest.cfm"
    "Tests for matcher functions" = {
        guid = "b006d2c420dd4cbe369b6c809c15ea83",
        file = "ttfMatcherFunctionsTest.cfm"
    "Tests for lifecycle functions" = {
        guid = "f93c3e12885f2913bfc8351ba1ed8911",
        file = "ttfLifeCycleFunctionsTest.cfm"

engineUrls = [
    "ColdFusion 2021" = "",
    "Lucee 5" = ""
writeOutput('<div class="tinyTest">');
testSuites.each((label, suite) => {
        method = "get",
        url = "",
        result = "testCodeResponse",
        throwOnError = true
    testCode = testCodeResponse.fileContent;
    engineUrls.each((engine, engineUrl) => {
        cfhttp(method="post", url=engineUrl, result="testRunResponse") {
            cfhttpparam(type="formField", name="setupcode", value=frameworkCode);
            cfhttpparam(type="formField", name="code", value=testCode);
            cfhttpparam(type="formField", name="asserts", value="");

(Gist on Github)

And the output's like this:

That'll do for the evening, I think.