Is there a way to run a single test class from the Eclipse IDE? I'm trying to debug a legacy test class and can run all tests in the Eclipse IDE - but that takes a while. I'm hoping to speed things up by running just that one unit test.

I can run that single test via the Developer Console unfortunately, viewing the debug log via the browser gets cut off because it's too long. However, the Eclipse debug log shows everything so that's where I prefer to operate.

Thanks, Scott

  • You can control debug log verbosity in the DC menu - 'Change Log Levels'; logs can be downloaded for easier viewing in text editors as well – cropredy Dec 23 '13 at 18:49
  • Agreed! I did turn everything to INFO except System and the output still maxed out. Part of the fun is trying different things and seeing the end result, but there's always deadlines to be met. :-/ – Scott Dec 23 '13 at 20:51
  • ooh - I always have System NONE because every time you execute a system.debug statement in your code, sfdc logs the entry into system.debug and the exit from system.debug. Useless noise. – cropredy Dec 23 '13 at 23:02

Sure you can :)

Right click either in the class' body or the *.cls file in the package explorer, then Force.com -> Run tests

enter image description here

| improve this answer | |
  • Spot on! I found the documentation (wiki.developerforce.com/page/An_Introduction_to_Force_IDE) which says: "You can activate the Apex Test Runner by selecting one or more Apex classes in the Package Explorer, then right-clicking and selecting Force.com > Run Tests. All Apex test execution occurs on the servers, so in order to use the Apex Test Runner view you must first save any changes." but being able to run the test by just having your cursor in the code is really cool! – Scott Dec 23 '13 at 18:53
  • 1
    It will still run the whole file and not just one test function but useful shortcut nonetheless. If you plan to do more with Eclipse - consider installing also the Mylyn tasks plugin: eclipse.org/mylyn – eyescream Dec 23 '13 at 19:00
  • Mylyn looks interesting. Not sure how to apply it yet but something worth investigating. I also noticed the presenters at Dreamforce '13 (e.g. Josh Birk) used sublime for deployments. I need to dig into that as well. – Scott Dec 23 '13 at 20:48
  • I find Mylyn helpful if you have multiple environments (dev/qa/production for example) and/or mutliple productions. And if you have to switch between several things you want to implement (it's very convenient to activate a task and immediately see it involved changes in these classes/triggers/pages; makes it easy to prepare a deployment package later too)... You can use it with local tasks but integration to JIRA etc is just an added bonus. – eyescream Dec 23 '13 at 20:55
  • Mylyn is great and it comes with base Eclipse now. Been using it for years, with hooks into JIRA and Bugzilla. Tasktop (sort of the professional version of Mylyn) is worth the money as well. Helps to lessen the loss of productivity due to context switching. – Peter Knolle Dec 23 '13 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.