• Amy C
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi All,

 

Writing my first test class here and fallen at the first hurdle!

 

To be able to test my class I need to instantiate a load of test objects first of all, so I have written a little class to do that which works fine.

 

The class I want to test is a (will be a) shopping cart that does nothing but instantiate so far.

 

I've started writing the test class to go alongside for my TDD. First I've instantiated all the test objects and written my first test method. However, Force.com IDE complains that objects are not available in my class. So when I try to save  

 

 

@isTest
private class TMDR_ShoppingCartTest {



	testBuildObjects tbo = new testBuildObjects();
	Account a = tbo.createAccount();
	Contact c = tbo.createContact(a.id);
	Opportunity o = tbo.createOpportunity(a.id,c.id);
	OpportunityContactRole ocr = tbo.createOpportunityContactRole(c.id,o.id);
	OpportunityLineItem oli = tbo.createOpportunityLineItem(o.id);
	OpportunityLineItem oli2 = tbo.createOpportunityLineItem(o.id);
	OpportunityLineItem oli3 = tbo.createOpportunityLineItem(o.id);
		
	static testMethod void testInstantiate() {
			
			System.Debug('########Starting Shopping cart tests###########');
			TMDR_ShoppingCart cart = new TMDR_ShoppingCart(o.id);
		
	}

}

 

 

 

 Force.com complains that o.id does not exist!

 

This must be a simple one. Can you help?

 

TIA