[Coldbox 6.1][Testbox 4.2.0] How Can I Write Tests For a Logbox Appender Written as a Coldbox Module?

I’m working on a really cool appender for Logbox which I plan on releasing to the community on Forgebox. However, I’m having a little difficulty writing tests, and getting things ready for publishing

My project structure looks like this currently (changed the names for simplicity):


I’d like to create a test harness so I can get jiggy with BDD, but I’m having difficulty getting started. I know I’ll need to create a test-harness folder with a self-contained app with its own box.json, but I’m not sure how to integrate MyCoolAppender.cfc as a part of that app for testing because it lives in the root of the project folder and not in the test-harness folder.

Here’s what I tried so far:
To gain some inspiration, I took a look at the mementifier project to see how it handles testing. From what I can see, mementifier, has a subfolder called /test-harness/ which contains an instance of Coldbox with its own box.json. From what I can tell, this sub-folder is meant to be its own self-contained app that can be tested against. What’s confusing to me is how the test-harness app is even aware of the mementifier interceptor. This seems like a similar approach that I was going to take, but I must be missing something!

I know my project is a little different because the test-harness (or the end-user) wanting to use my appender will need to add it to the struct of appenders in the logbox section of /config/coldbox.cfc.

I scanned the Testbox documentation (https://testbox.ortusbooks.com/) and didn’t see much on how to write tests for submodules (or maybe I completely missed it).

If anyone has any tips or can point me in the right direction on how I can create a test-harness and configure it to use MyCoolAppender, it would be most appreciated.

Thank you!


The trick is that the app has two areas that bootstrap the parent folder as the module roots.

1) The Application.cfc has a mapping back one folder to map as the module
2) The config/ColdBox.cfc has a listener that registers the module upon app configuration

This allows for the embedded test harness to look back and register the module. You can find our module template and instructions here: GitHub - coldbox-modules/module-template: The automated template we use to build core Ortus modules

Luis Majano
Ortus Solutions, Corp

Support Open Source: www.patreon.com/ortussolutions
Linked In: https://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/lmajano

Outstanding! Thank you. I will bookmark the module template repo and start
playing with it.

I have a follow-up question when creating a test-harness “app”: How would you handle javascript dependencies within the module if the module has front-end components? My understanding is that the “test-harness” is really like a sample app that implements the module being tested. Therefore, since the module lives up a folder instead of in the ‘modules’ folder, there wouldn’t be any way for the browser to reference any client-side resources (css, js, images, etc) that exist within the module.


// module root
/ models
/ resources / js / funky.js

// test harness
/ test-harness / 
/ test-harness / layouts / main.cfc

If the test-harness main layout needs /resources/js/funky.js, there wouldn’t be a way to reference it when building the app. In a tracked module, you would reference it like this:
/modules_app/myModule/resources/js/funky.js. However, in this test-harness setup, I don’t see a way to virtually reference the parent folder (without some creative IIS/web server mappings I suppose)

Does my question make sense?