David Levin, Author at FusionReactor Observability & APM https://fusion-reactor.com/author/david-levin/ Thu, 04 Aug 2022 11:09:06 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 https://fusion-reactor.com/wp-content/uploads/2024/03/cropped-icon-32x32.png David Levin, Author at FusionReactor Observability & APM https://fusion-reactor.com/author/david-levin/ 32 32 Troubleshooting TestBox Code Coverage with FusionReactor https://fusion-reactor.com/blog/evangelism/troubleshooting-testbox-code-coverage-with-fusionreactor/ Thu, 04 Aug 2022 11:09:06 +0000 https://fusionreactor.dev.onpressidium.com/?p=69635 This blog will investigate troubleshooting TestBox Code coverage using FusionReactor. What is TestBox? TestBox is a robust testing framework for ColdFusion (CFML) that many developers rely on for producing both unit and behavior-driven (BDD) tests for their web applications. What … Read More

The post Troubleshooting TestBox Code Coverage with FusionReactor appeared first on FusionReactor Observability & APM.

]]>

This blog will investigate troubleshooting TestBox Code coverage using FusionReactor.

What is TestBox?

TestBox is a robust testing framework for ColdFusion (CFML) that many developers rely on for producing both unit and behavior-driven (BDD) tests for their web applications.

What is Code Coverage?

Code Coverage is a metric that provides the percentage of your source code which is included in the tests that you write. If your code coverage score is too low, it is usually an indicator that you must write more tests. Many developers rely on code coverage statistics to help determine how complete their tests are.

TestBox supports code coverage reports if you have a licensed copy of FusionReactor connected to the tested web application. The easiest way to do this is via Commandbox.

I recently ran into issues with code coverage reporting while running tests for a ColdBox application I was developing for a client. My tests were executed successfully, but the code coverage statistics weren’t updating, and the information displayed didn’t reflect my actual code. The summary results showed files from the ColdBox framework which should be ignored by default.

troubleshooting testbox

I put together some troubleshooting tips based on my own experimentation and the assistance I received from Brad Wood on the Ortus Community Forums.  The forums are a great resource for anyone looking to discuss ColdBox, TestBox, and more.

Troubleshooting TestBox Code coverage Tips:

Make sure your /tests/ folder is fully up to date with the latest version.  When you run package update in Commandbox, it updates the framework and any dependencies you have installed, but it will not touch the files in your /tests/ folder, which includes the TestBox Browser.  Therefore, I recommend visiting the latest version of the ColdBox advanced script template to make sure your version is up to date.  If you replace your copy of /tests/Application.cfc, make sure to reconfigure it for your testing needs. For example, you may need to include your data source and/or ORM settings.  Also, be careful not to overwrite the /tests/specs/ directory because that is where your tests live.

troubleshooting testbox

Code Coverage only works if you have a valid FusionReactor License.  Type fr open in Commandbox and log into FusionReactor, you should see a green message on the screen that indicates your license is active.  If you do not have a license, I recommend picking up a Developer license subscription or a free trial license.

If you run your tests using the “Run All” button from the TestBox Browser located at http://[your host]/tests/, Code Coverage will not execute and will instead show inaccurate code coverage statistics.  Code Coverage statistics will also not show if you run individual “a-la-carte” tests.  Code coverage will only generate if you execute all of your tests via the URL http://[your host]/tests/runner.cfm.

troubleshooting testbox

Make sure to delete the /tests/results/coverageReport folder as an added precaution.

You will know when the coverage report is generated properly when you see the “Coverage Browser generated in…” message on the result screen, and you see your own app’s files listed in the “Files with best coverage” section.

troubleshooting testbox

Hopefully, these tips will help you in your journey using code coverage in your tests. If you have other tips for troubleshooting code coverage with TestBox and FusionReactor, please feel free to submit them in the comments.

About the Author:

David Levin is a freelance web developer and CEO of Angry Sam Productions with over 23 years of experience developing custom ColdFusion (CFML) web applications, websites, and web hosting solutions.

The post Troubleshooting TestBox Code Coverage with FusionReactor appeared first on FusionReactor Observability & APM.

]]>
A Beginner’s Guide to Troubleshooting Slow Pages in FusionReactor https://fusion-reactor.com/blog/evangelism/a-beginners-guide-to-troubleshooting-slow-pages-in-fusionreactor/ Mon, 23 Aug 2021 15:26:34 +0000 https://fusionreactor.dev.onpressidium.com/?p=65140 Beginner’s Guide to Troubleshooting Slow Pages in FusionReactor By: David Levin, CEO and Big Kahuna of Angry Sam Productions, Inc. It happens to just about every developer, client, or boss who calls out of the blue and complains that one … Read More

The post A Beginner’s Guide to Troubleshooting Slow Pages in FusionReactor appeared first on FusionReactor Observability & APM.

]]>

Beginner’s Guide to Troubleshooting Slow Pages in FusionReactor

By: David Levin, CEO and Big Kahuna of Angry Sam Productions, Inc.

It happens to just about every developer, client, or boss who calls out of the blue and complains that one of their essential web apps is running slowly. “Wonderful,” you sarcastically say to yourself as you can barely recall how their app even works since you haven’t looked at it in over six months! So how do you begin troubleshooting slow pages?

The good news is that there’s an easy way to diagnose, debug, and troubleshoot performance issues without having to sift through thousands of lines of embarrassing legacy code. In this blog post, I will describe how to install and use FusionReactor, a ColdFusion/Lucee (CFML) application performance monitoring tool, so you can save the day and look like a hero to your boss and/or client.

Installing FusionReactor

I am going to assume you are running your CFML development servers using CommandBox.  If you are not, you really should be these days.  Installing FusionReactor is as simple as typing these two commands into the CommandBox CLI:

fusionreactor register XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

You’ll want to replace XXXXX-XXXXX-XXXXX-XXXXX-XXXXX with your actual serial number.  If you don’t have a serial number, you can pick one up with 14-day free trial

Setting Up the Bean Counter Application

The bean counter app is pretty simple. All it does is execute a query and display the total number of records found in the database.  If you like, you can download the source code of the app on
Once you have the codebase downloaded, navigate to the project directory and spin up a new server in CommandBox with the following command:

server start

You will need to create a new data source for this example. I created a new MSSQL database called “beancounter” on my development machine with a single table called “bean.” You can create any column(s) inside the table you wish.  You will also need to add the DSN to Lucee‘s Server Admin. Hint, the default password for Lucee/ColdFusion servers created in CommandBox is “commandbox”

After the server starts, if you don’t automatically see the bean counter home page, you can manually bring it up by typing the following in CommandBox:

The application home page loaded pretty quickly, so I don’t think there’s a problem there. Try counting all of the beans by clicking the link on the page.

Houston, we have a problem.  The bean-counting page loads painfully slow.  Surely it can’t take this long to count 0 beans!  The good news is that we successfully replicated the client’s problem.

Troubleshooting Slow Pages using FusionReactor

The first thing we should do is open FusionReactor to dig deeper into what’s going on behind the scenes of our slow-running page.  In the CommandBox CLI type: fusionreactor open

You should be taken directly to the FusionReactor login screen.  The default password for CommandBox installations is “commandbox” If you’re using this in production, you should pick a strong password and safely store it in your password manager of choice.  Once logged in, you will see the primary dashboard.  You can confirm you are viewing the proper app by checking the name in the upper right-hand corner.  It should match the name of your server in CommandBox.

When hunting for performance problems, the first place I start is the request history.  Click on the Requests button on the left navigation menu and select “History” from the list of drop-down items. 

We should then see the WebRequest Transaction History screen, which displays a chronological list of requests in descending order.  Right off the bat, we can see we have a problem – FusionReactor has even highlighted the slow request for us in bold red text:

 

troubleshooting slow pages

To dig deeper into the problem of troubleshooting slow pages, click the details button on the right-hand side of the screen next to the request we want to analyze.  You will then be taken to the Details screen.

The Details screen can be a bit overwhelming at first, so let us focus on a few basics.  In the upper left-hand corner of the Transaction Details section, we can see the request’s status, which indicates that the request finished successfully.  We also can see some information about the script path and URL that was used in the request.  In our case, the troublesome page was the aptly named /slow-page.cfm.

troubleshooting slow pages

On the right-hand side of the same tab, we can see the total execution time of the request. In this case, it took about 13.5 seconds to finish.  Ouch!

Another vital part of the transaction details is the JDBC section. It summarizes all database operations that occurred during the request.  In our case, we can see that 1 query was executed, and it took over 5 seconds.

Another handy feature of analyzing a request is called the Profiler.  Click on the “Profiler” tab to get a more detailed view of what occurred during the request.  FusionReactor does a good job hiding a lot of the unimportant stuff and only shows us the methods which took the longest time. In addition, everything is color-coded to make identifying trouble spots much easier to identify.

As you can see from the tree above our query only took up about 12% of the request while 87% was spent sleeping!  

Debugging SQL

One of the most common performance problems people encounter relates to SQL operations or database communication.  In our example, we have a troublesome query, so let’s start there to see if we can identify the exact problem. First, click on the JDBC tab on the transaction details screen. Then, FusionReactor can show us the exact SQL statement(s) executed for simple debugging.  

It looks like someone added an intentional delay to the query statement! Who would do that? Lucky for us, this is going to be an easy fix.  However, you may need to troubleshoot your query a bit more in-depth in a real-world situation.  More often than not, you can fix slow SQL  by ensuring your database is optimized with proper indexes and through other best practices.  

Fixing the slow pages in your Application

At this point, we learned that our page, /slow-page.cfm, has two significant problems:

  1. There’s a poorly written SQL statement that needs fixing
  2. There’s some sleep code in place which delays page execution.

Next, we open /slow-page.cfm in our IDE of choice.  As you can see, whoever wrote this page likely had some serious psychological issues. So let’s get to work fixing the page:

After some clever optimization, we can clean up the page with the following changes:

Checking Our Work

Once we have saved the changes to the slow page, re-run the requests in your web browser before returning to FusionReactor.  You should notice that the page executes noticeably faster.  

Switch over to FusionReactor and click on the Request history again.

troubleshooting slow pages

Bingo. The request only took 6ms to execute. You can now deploy your changes and look forward to accepting your hero medal from your client and/or boss.

A Happy Ending

FusionReactor is a powerful ally to have in your pocket whenever you develop or troubleshoot slow pages.  It can help you identify bottlenecks in your software even before you deploy to production.  If you’d like to learn more about FusionReactor, be sure to check out FusionReactor’s videos for a variety of tutorials and different ways to help your CFML development processes.

If you’re interested to learn more about me or my freelance web development or consulting services, please check out my website, or you can message me on Twitter.

The post A Beginner’s Guide to Troubleshooting Slow Pages in FusionReactor appeared first on FusionReactor Observability & APM.

]]>