[SalesForce] Force a Unit Test to run immediately inside Salesforce Web UI

Is there a way to force a unit test to run immediately? You used to be able to go to App Setup > Developer > Apex Classes > [ClassName] > Run Test button. This used to begin processing a unit test right away. With the new changes to how unit tests are run, this now just queues up the test in the Apex Test Execution page. So, outside of that, you can just use the Apex Test Execution page and select the tests you want to run as well. However, like the previous issue, that simply queues up the test and Salesforce determines when it should start up. Finally, from the web interface, you can use the Developer Console. However, the Developer Console functions exactly the same as the Apex Test Execution page and simply queues it up.

I am trying to follow TDD as well as possible in the Salesforce environment, but waiting for these queued up tests is taking too long. It can take anywhere from a second to a few minutes for these tests to finally run. I understand I can use Eclipse, but I have had several issues in the past where it simply takes much longer in Eclipse than it would through the UI. I am just trying to see if there is a way to force a test to run immediately rather than having to wait for Salesforce to decide it wants to run the test.

Best Answer

Nope. :(

Ever once in a while these things stay queued forever, but normally it's very fast. IMHO, this is going to be a good thing since my biggest pet peeve is waiting ~45minutes for a deployment to validate (the whole time seeing 1 error teasing me in the window) while all tests run serially. Running all tests in the same org via the test execution framework is about 4-5x faster. Hopefully the next step in the roadmap is to use this for deployments and get those back to being reasonable!!

As a final note, I love Test Driven Development (TDD), but as of today, it's not all that viable a strategy for Salesforce.

Related Topic