Just like many of us these days, my todo list keeps getting longer and longer. One of those things that I never get enough time to do is blog, and contribute articles to the developer community. My current project is an article on test patterns and best practices I desperately want to get wrapped up before Dreamforce

One of the sections in this article shall talk about the difference between test cases and test suites. Wikipedia describes a test case as "a set of conditions or variables under which a tester will determine whether an application or software system is working correctly or not." And a test suite as "a collection of test cases that are intended to be used to test a software program to show that it has some specified set of behaviours."

The difference is subtle but important when we look at building our tests on the Force.com platform. The important is further magnified as more and more people leverage the platform for complete solutions which extend the Salesforce.com product offerings, or invent something completely unique.

But this is a developer blog, so let's jump to the code.

From the docs, a typical test case might look like the following, with generally 1..n testMethods.

This is a great start, but as we start to look at test suites, I might want to test the complete end-to-flow of piece of the application, or user story to borrow a term from Scrum. To support such a framework I often use a single testMethod as a 'wrapper', and then separate the logical (business) functions I want to test into methods, starting with a setup method to initialize all the objects I might need. Below is a snippet from a test suite which should demonstrate the idea (and the difference) of how you can create test suites to model the business process of your app.


  * Contains all the test cases for user stories use cases



private class UserStoryTestSuite {

static Theme__c themeSO = null;

static Scrum_Team__c teamSO = null;

static Release__c releaseSO = null;

static Sprint_Backlog__c backlogSO = null;

static testMethod void manageUserStory()











static void setup()


teamSO = TestHelper.createScrumTeam('Test Scrum Team');

themeSO = ThemeTestHelper.addTheme(teamSO);

releaseSO = ReleaseTestHelper.createRelease(); 

backlogSO = BacklogTestHelper.createBacklog('Backlog Test', teamSO);


//the rest of the class has been removed for brevity.

 The article I mentioned at the start of this post will contain a lot more detail, but for now hopefully this will spur some food for thought.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS