Okay I've written my code and tested it in my sandbox; works as expected. When I tried to move it to production, I ran a the deployement test and I received the following msg: "Coverage of selected Apex Trigger is 0%...." . Can someone help me write a test class?
Below is my Trigger Code:
trigger CreateTicket on Maintenance_Request__c(after update)
No, you can't deploy a trigger to production without a unit test.
Here is what you need to get started. This unit test will satisfy the requirement for production and will allow you to deploy your code. However you should add logic to the unit test to check that the trigger did what it should have done.
Did you include your unit test in the deployment package? You said you tested your tirgger in the sandbox so you have a unit test already right? If not then you didn't test it.
This is my first trigger and am very unfamiliar with demployement from sandbox to production. If the unit test is not auto created by the trigger, then the answer is no. Instructions on how to include it in the deployement is greatly appreciated.
So from Eclipse just add the trigger and the unit test for the trigger to the deploy package. You can multi select the files from the package explorer using the Ctrl key then right click one of the files and select Force.com --> Deploy to server. Good luck!
No, you can't deploy a trigger to production without a unit test.
Here is what you need to get started. This unit test will satisfy the requirement for production and will allow you to deploy your code. However you should add logic to the unit test to check that the trigger did what it should have done.
No, you can't deploy a trigger to production without a unit test.
Here is what you need to get started. This unit test will satisfy the requirement for production and will allow you to deploy your code. However you should add logic to the unit test to check that the trigger did what it should have done.
All Answers
Did you include your unit test in the deployment package? You said you tested your tirgger in the sandbox so you have a unit test already right? If not then you didn't test it.
This is my first trigger and am very unfamiliar with demployement from sandbox to production. If the unit test is not auto created by the trigger, then the answer is no. Instructions on how to include it in the deployement is greatly appreciated.
It would be nice if the unit test was auto created but no dice! You need to write it your self. Here is a wiki you should read: http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods
After you write your unit test then deploy your trigger and your unit test to production. What tool are you using to deploy?
I will give it a try. Thanks!
I'm using Force IDE on eclipse.
Eclipse is what I use most of the time.
So from Eclipse just add the trigger and the unit test for the trigger to the deploy package. You can multi select the files from the package explorer using the Ctrl key then right click one of the files and select Force.com --> Deploy to server. Good luck!
I read the guide in the link provided. Not sure what to do after the first few lines.
Can the code be doployed without being tested?
No, you can't deploy a trigger to production without a unit test.
Here is what you need to get started. This unit test will satisfy the requirement for production and will allow you to deploy your code. However you should add logic to the unit test to check that the trigger did what it should have done.
You sir are a genious! Thanks!