Running module test error

So I have pulled the repo for the cbvalidation module.

I can run the server and the main test page works great after adding the /coldbox mapping for the virtual app. (FYI: excellent error message to explain this.)

But if I try to execute any of the Manager or Validation test I get this error:

tests/specs/ValidationManagerTest.cfc
tests/specs/validators/RangeValidatorTest.cfc
/p/cbvalidation/test-harness/coldbox/system/testing/BaseTestCase.cfc: line 7
5: * Base testing component to intergrate TestBox with ColdBox
6: */
7: component extends="testbox.system.compat.framework.TestCase" accessors="true" {
8:
9: /**

called from /p/cbvalidation/test-harness/tests/specs/ValidationManagerTest.cfc: line 6

My guess is that there is a testbox mapping missing as well.

I’m confused. What error? I see filenames and a code snippet. What is the error message?

You could be right on the testbox mapping issue. If testbox isn’t installed inside a testbox/ directory in the root of your application (in this case, at /p/cbvalidation/test-harness/testbox) then you will need a /testbox mapping in order for the extends="testbox.x.y.z" to resolve.

Sorry duh.

invalid component definition, can't find component [testbox.system.compat.framework.TestCase]

Clearly the issue is a mapping for testbox.
And I can figure out where to place it but I am confused about something.
I am assuming that the people that work on this module and the others actually run the test they have created when developing.

What is the default/normal way of executing this test and or all of the tests that does not require code changes which may pollute the module?

I was actually surprised that I did not see a run all tests link on the home page of the test-harness or on the main view of the app for the module.

invalid component definition, can’t find component [testbox.system.compat.framework.TestCase]

Yep, definitely a testbox mapping issue.

What is the default/normal way of executing this test and or all of the tests that does not require code changes which may pollute the module?

For simply running all tests, the standard practice is to use the box testbox run command which uses CommandBox to fire an HTTP request to /tests/runner.cfm by default.

Since it looks like your test harness is located at test-harness/ you’ll need to amend that by running:

box package set testbox.runner="/test-harness/tests/runner.cfm"

You can also tweak the runner settings to run specific “bundles” or labels like a label=“security”` annotation on the test component. This can be super handy for running only specific tests! Otherwise, you’d click through the test browser to run tests individually.

For more details, check the docs:

That makes sense but we are still missing a testbox mapping in this module:


cbvalidation/test-harness/tests/runner.cfm: line 13

    11:
    12: <!--- Include the TestBox HTML Runner --->
    13: <cfinclude template="/testbox/system/runners/HTMLRunner.cfm" >
     
Java Stacktrace lucee.runtime.exp.MissingIncludeException: Page /testbox/system/runners/HTMLRunner.cfm [/p/cbvalidation/testbox/system/runners/HTMLRunner.cfm] not found

Where would be the best place to include that?
And it is still odd that I would have to tweak this in the module.

So I started with a clean pull of the repo.
ran box to enter commandbox from within the repo dir.
ran the setup script and set the test folder

run-script install:dependencies
package set testbox.runner="/test-harness/tests/runner.cfm"

Exited box
Added the coldbox mapping to the test-harness/Application.cfc

+               this.mappings[ '/coldbox' ] = '/home/me/repos/cbvalidation/test-harness/coldbox/'

Then added the same coldbox mapping as well as a testbox mapping to test-harness/tests/Application.cfc

+               this.mappings[ '/testbox' ] = '/home/me/repos/cbvalidation/test-harness/testbox/'
+               this.mappings[ '/coldbox' ] = '/home/me/repos/cbvalidation/test-harness/coldbox/'
                request.coldBoxVirtualApp= new coldbox.system.testing.VirtualApp( appMapping = "/root" );

Rentered box:

testbox run

Everything ran perfectly.
Thank you for the help

2 Likes