You need to sign in to do that
Don't have an account?

Test Method Coverage
I have created a Trigger on our sandbox that works great when we upsert from the Data Loader:
trigger ProductTrigger on NRProducts__c (before update, before insert) {
for(NRProducts__c r : Trigger.new){
if(r.Name == null){
r.Name = 'NEWPRODUCT';
}
}
}
I have written the following test method:
public class ProductTrigger {
static testMethod void myTest() {
// Create that new product record.
NRProducts__c r = new NRProducts__c(name='NEWPRODUCT');
insert r;
// Verify that the name field was set as "NEWPRODUCT".
NRProducts__c insertNRProducts = [SELECT name FROM NRProducts__c WHERE Id = :r.Id];
System.assertEquals('NEWPRODUCT', insertNRProducts.name);
}
}
It compiles, however when I ran test coverage it comes back as 66% with the following
trigger ProductTrigger on NRProducts__c (before update, before insert) {
for(NRProducts__c r : Trigger.new){
if(r.Name == null){
r.Name = 'NEWPRODUCT';
}
}
}
Any thoughts on how to make the test method complete?
You're not satisfying the conditional. Try this:
All Answers
You're not satisfying the conditional. Try this:
This was the solution! Thank you very much for your help! Much appreciated!