+ Start a Discussion
AnicheAniche 

Trigger Deployment thru Eclipse

All,
 
I have used to Force.com IDE in Eclipse to build my trigger and before i even write my Unit Test method i want to know to the steps that i have to do through eclipse move my code from sandbox to prod.
 
I tried to click on validate option when i  right click on the trigger and gives me an error
 
Severity and Description Path Resource Location Creation Time Id
cvc-complex-type.2.4.a: Invalid content was found starting with element 'active'. One of '{"http://soap.sforce.com/2006/04/metadata":fullName, "http://soap.sforce.com/2006/04/metadata":content, "http://soap.sforce.com/2006/04/metadata":apiVersion}' is expected. Account/src/unpackaged/triggers AccountT.trigger-meta.xml line 3 1202486922621 690
" How do i get the Test coverage 0% " error.
 
Thanks in advance
Anish
JonPJonP
There are two things going on here.

First, your Sandbox environment was upgraded to Spring '08 (API 12) but your production environment is not upgraded yet (API 11).  This is part of how we do rolling upgrades of the service, making new features available for advance testing in Sandbox.  More of our service was upgraded over the previous weekend, so it's possible this problem will have resolved itself.  But if not, see this thread:

http://community.salesforce.com/sforce/board/message?board.id=apex&thread.id=2547

Specifically, the validation problem you are seeing is that the 'active' element was added in the upgrade from API 11 to API 12, and the Winter '08 version of the Force.com IDE doesn't know about it.  The link above goes into details.


The second problem here is that the "validate" command in the IDE simply validates the XML of a file, it doesn't run any tests.  So while validating your file reveals that the IDE thinks "active" is an invalid XML attribute, that doesn't tell you anything about your Apex Code.

What you actually want to do is create an Apex Class to house your unit tests, then right click on it, and on the context menu choose Force.com > Run Tests.  This will execute your Apex Class on the server, and the results will appear in the IDE's "Apex Code Test Runner" tab (usually found in the bottom section of the screen).  Note that you cannot "run" Apex triggers directly; you can only test them by running an Apex Class that contains test methods, that in turn perform the appropriate DML actions to fire the trigger.

Hope this helps!




Message Edited by JonP on 02-12-2008 09:47 AM

Message Edited by JonP on 02-12-2008 09:48 AM
AnicheAniche
Thanks Jon this truely helps.. Now i am getting a hang of it :)
KaydanceKaydance
Just want to clarify,
To test my Apex Trigger I need to create an Apex Class?
Are there any references/tutorials to building a test class?

I need some direction, in my case I've built a simple apex trigger in my sandbox and verified it works. I had to recreate the trigger in eclipse (because I could find no information on going from sandbox to production inside of SFDC) Now when I go to deploy the trigger I get all kinds of errors and warnings about 0% testing/ requires at least 1%... So do I need to write a class from scratch that mimics the Accounts functionality (this is what object the trigger is associated with)???

Message Edited by Kaydance on 10-15-2008 01:48 PM
JonPJonP
The Apex Language Reference (http://www.salesforce.com/us/developer/docs/apexcode/index.htm) has a thorough treatment of writing Apex unit tests under the "Debugging Apex" section.
KaydanceKaydance
Thank you! I will look there.
RamaRoopaRamaRoopa
Hi, I installed Ecilipse in my system. I created the trigger in the developer edition. I want to move the trigger into the production. Can anyone guide me the steps hownto move the trigger into the production from the developer edition.