Your test didn't work properly because of you use only insert
operation, but your trigger works on update
mode. So, you have to change test or trigger or both
@isTest
private class MDwinningTest {
@isTest
static void MDwinningTest() {
// prepare test data
MD_Meeting__c m = new MD_Meeting__c(
Account__c = 'test Account',
Desired_Meeting__c = 'Call',
Name = 'Meeting name',
Sales_Director__c = 'SD Name',
Market_Developer__c = 'MD Name',
Meeting_Date__c = Date.today(),
Contact__c = 'Test Contact',
Title__c = 'Boss',
Functional_Role__c = 'eCommerce - VP',
Contact_Email__c = 'test@aol.com',
Primary_URL__c = 'http://www.google.com/'
);
insert m;
m.SD_Action__c = 'Generate Opportunity';
update m;
System.assertEquals(1, (Integer)[SELECT Count(Id) FROM Opportunity][0].get('Expr0'));
}
}
I suggest to disable SeeAllData = true because it risky because some of org where your code might be deployed might have no needed data and as a result your tests will be broken
Also you can change the current trigger for working on insert and update
trigger MDwinning on MD_Meeting__c (after insert, after update) {