You need to sign in to do that
Don't have an account?
Geoffrey Nix
Trying to run a test class to test a method that uses batchable apex to retrieve Opportunities with less than 30 days til close and give a 10% discount to those Opportunities. My code is below and I'm getting errors
@isTest
private class NotifyClosingOppsTest {
@testSetup
static void setup(){
Opportunity [] opps = new List <Opportunity>();
for(Integer i=0; i<50; i++) {
opps.add(new Opportunity(Name ='Tester ' +i,
CloseDate = date.newInstance(2020, 1, 1), Stage = 'Needs Analysis'));
}
insert opps;
static testmethod void test() {
Test.startTest();
NotifyClosingOpps oppTester = new NotifyClosingOpps();
Id BatchId = Database.executeBatch(oppTester);
Test.stopTest();
System.assert(Opportunity.CloseDate < 30);
}
}
}
private class NotifyClosingOppsTest {
@testSetup
static void setup(){
Opportunity [] opps = new List <Opportunity>();
for(Integer i=0; i<50; i++) {
opps.add(new Opportunity(Name ='Tester ' +i,
CloseDate = date.newInstance(2020, 1, 1), Stage = 'Needs Analysis'));
}
insert opps;
static testmethod void test() {
Test.startTest();
NotifyClosingOpps oppTester = new NotifyClosingOpps();
Id BatchId = Database.executeBatch(oppTester);
Test.stopTest();
System.assert(Opportunity.CloseDate < 30);
}
}
}
-greg