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

20 views
Skip to first unread message

David Levin

unread,
Nov 18, 2020, 6:14:48 PM11/18/20
to ColdBox Platform
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):

/logging/
/logging/MyCoolAppender.cfc
/ModuleConfig.cfc
/box.json

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!

Luis Majano

unread,
Nov 24, 2020, 10:13:04 PM11/24/20
to ColdBox Platform
David,

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: https://github.com/coldbox-modules/module-template
--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/4dfe0cba-3494-4654-b1e7-63fbf55e7de9n%40googlegroups.com.

David Levin

unread,
Nov 25, 2020, 3:09:32 PM11/25/20
to ColdBox Platform
Outstanding! Thank you.  I will bookmark the module template repo and start playing with it.
Reply all
Reply to author
Forward
0 new messages