Unit Testing in ColdBox Best Practices?

What are the best practices for Unit Testing in ColdBox?

I see the samples that come in the test directory.

However if you have a handler that has a lot of events, do you create a test case for each handler? or break them up?

If I run the testsuite.cfm it times out if I have very many tests. So do I create mulitple testsuite files?

Does anyone have examples of what they do?

How many use the Unit Testing IN ColdBox?

Is there a best practices even available?

Thanks for any help,
Nathan

Nathan,

Personal I do this.

unitTests->handlerName

If the handler is is a package then it becomes

unitTests->packageDir->handlerName

Each handlerName contains a test for each action, inside each action test I test for every known condition for that test handler.

There was a discussion about this some time ago, and I prefer this way because if a test on a handler has many conditions I consider it to not be passed until all conditions have run.

Now one could argue the same for a separate test method for each condition, but as I use Ant and the mxUnit view I find that when writing the test it easier to run the one test than multiple tests. Especially at the time of writing the tests.

Others will disagree and think the opposite, but when you have been writing tests for as long as I have and your time is precious you don’t want to be running multiple tests for one handler action.

Some might argue that you just run the test via the RMB on the file, but if you have say 30 handler actions and each handler action could potentially have multiple conditions then the time it takes to run that one file can be an issue. Then take into consideration how many times you might run that test while developing it, then you quickly discover how much time is wasted.

I have seen complete tests take up to 6 hours to run, mind you that was in a Java application and was very complex. But the point is that sort of downtime if it can be minimised is something everyone should consider.

So as a time saver, as I consider my time important. The way I have described means you can click on the view and just click the one test. This would ensure that you also don’t accidentally miss a test condition as well, which would increase the chances that you introduce problems into your tests. And then that would mean that the only way to overcome that would be to run all tests and again wasting development time.

The last time I was pretty much shot in the foot over this, and I challenge anyone who is actually serious about their tests to consider that this way does save time, and money.

One of the problems I have is if I use the integration folder under the TEST folder and I put 6 tests it times out before finishing. I do not even have any assertions. I am just using the sample templates that were in the advanced ColdBox application. Why have such a small group of tasks does it time out?

You don’t make it clear but is this the mxUnit view?

Set the timeout value to 0 in mxUnit preferences.