function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Graham Booth 11Graham Booth 11 

How To Create Basic Code Coverage

Is there any way of creating a basic Code Coverage Class to allow me to move the changes to Production?

The visualforce page I have is simply to have an output in PDF format.  There is no record update or inserts.  Is there anyway of creating somewhich will allow me to push the code to Production

thanks
Leonardi KohLeonardi Koh
There isn't really a way to generate general purpose code coverage since this depends entirely on the code we have in the first place.

For example if you have a VF page with PDF format output, i assume you have a controller class or component for retrieving the data to be displayed on the PDF. (The VF page itself doesn't need coverage)

The basic code coverage for it then would be using test class that simulates the controller class being called and used for the VF page, and if that controller class needs information from other SObject record we'd have to create those as well in the test class so your controller class can simulate the process and thus cover them.

There is technically a way to cheat Salesforce 75% requirement for deploying into production in the test class, but this is something we don't want to do unless we for some reason need to deploy NOW, and damn all the consequence.
Graham Booth 11Graham Booth 11
Hi,
as previously stated, I am extremely new to this and and may have got a little confused.  When I have tried to deploy again, I have checked the errors and the errors are:
Code Coverage Failure
The following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.
DefaultName_Sibling
DefaultName

Seems I found the way around test classes for the Visualforce page (This actually just uses Standard Controller and then uses the Related List command), but have the problem with the triggers.

The biggest issue is that I am new to writing code, have been an admin for many years, but decided to support a Charity and deploy Salesforce but trying to get this POC up and running before they open their doors.

Any suggestions on how to get this done?

thanks