• msneller
  • NEWBIE
  • 35 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
When deploying some updates to exiting apex classes, the deploy is failing because it says 0% code coverage. When I check coverage in the developer console it shows 83% coverage. Not sure what is going on. This just starting happening this week, I deployed a few changes last week without issue. Nothing has been changed or packages added in the meantime. I've had this issue in the past, but usally went away after 24 hours. Any ideas? Is this a bug?

Does anyone know why this will not find the match.

I'm running this code

	public string cleanEmail(String body){
		String result;
		system.debug(body);
		String RegExp = '(?m).*^From:.*\\n^Sent:.*\\n^To:.*\\n^Subject:.*'; 
		
		Matcher m = Pattern.compile(RegExp).matcher(body);
		if (m.matches()) {
			Integer position = m.start();
			result = body.substring(0, position);
		}else{
			result = 'No match';
		}
		return result;
	}

 

The string "body" equals the following and should find a match.

 

email Test 6

 

From: xxxxx@xxxxxx.com
Sent: Wednesday, December 11, 2013 7:07 AM
To: 'xxxxx@xxxxxx.com'
Subject: FW: Case email testing

 

Junk

I'm creating a test method, but whenI try to select from the database I get "System.QueryException: List has no rows for assignment to SObject"

 

Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];

 

I've run the query in the force.com IDE and it works, I get the row that I expect. I don't know why its returning 0 rows when the test run. Any ideas?

 

Thanks in advance!

 

(FYI - I'm new to apex, this is only my second trigger/test method)

 

Here's the code:

@isTest
private class Test_Opp_Create_Contract_Entitlement {

static testMethod void myUnitTest() {
//create our test account
Account a = new Account();
a.name = 'test';
a.type = 'A+';
a.industry = 'Other';
a.billingcity = 'd';
a.billingcountry = 'USA';
a.billingState = 'co';
a.billingstreet = 'unknown';
a.billingpostalcode = '80204';
a.phone = '3039291726';
insert a;


//Create an opportunity
Opportunity o = new Opportunity();
o.Name = 'test';
o.AccountId = a.id;
o.Type = 'Infor (OEM)';
o.CloseDate = date.today();
o.StageName = 'Qualified';
o.LeadSource = 'other';
insert o;

Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];

Product2 p = new Product2();
p.Cost__c = 10;
p.Name = 'testp';
p.ProductCode = '12345';
p.Family = 'Software Support';
p.Create_Service_Contract_when_Sold__c = true;
insert p;

PricebookEntry pbe = new PricebookEntry();
pbe.Product2Id = p.id;
pbe.UnitPrice = 100;
pbe.Pricebook2Id = standardPB.Id;
pbe.IsActive = true;
insert pbe;

test.startTest();
//add line item
OpportunityLineItem oli = new OpportunityLineItem();
oli.OpportunityId = o.id;
oli.PricebookEntryId = pbe.Id;
oli.UnitPrice = pbe.UnitPrice;
oli.Quantity = 10;
insert oli;

//update status
o.StageName = 'Closed Won';
update o;
test.stopTest();

}
}

 

When deploying some updates to exiting apex classes, the deploy is failing because it says 0% code coverage. When I check coverage in the developer console it shows 83% coverage. Not sure what is going on. This just starting happening this week, I deployed a few changes last week without issue. Nothing has been changed or packages added in the meantime. I've had this issue in the past, but usally went away after 24 hours. Any ideas? Is this a bug?

Does anyone know why this will not find the match.

I'm running this code

	public string cleanEmail(String body){
		String result;
		system.debug(body);
		String RegExp = '(?m).*^From:.*\\n^Sent:.*\\n^To:.*\\n^Subject:.*'; 
		
		Matcher m = Pattern.compile(RegExp).matcher(body);
		if (m.matches()) {
			Integer position = m.start();
			result = body.substring(0, position);
		}else{
			result = 'No match';
		}
		return result;
	}

 

The string "body" equals the following and should find a match.

 

email Test 6

 

From: xxxxx@xxxxxx.com
Sent: Wednesday, December 11, 2013 7:07 AM
To: 'xxxxx@xxxxxx.com'
Subject: FW: Case email testing

 

Junk

I'm creating a test method, but whenI try to select from the database I get "System.QueryException: List has no rows for assignment to SObject"

 

Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];

 

I've run the query in the force.com IDE and it works, I get the row that I expect. I don't know why its returning 0 rows when the test run. Any ideas?

 

Thanks in advance!

 

(FYI - I'm new to apex, this is only my second trigger/test method)

 

Here's the code:

@isTest
private class Test_Opp_Create_Contract_Entitlement {

static testMethod void myUnitTest() {
//create our test account
Account a = new Account();
a.name = 'test';
a.type = 'A+';
a.industry = 'Other';
a.billingcity = 'd';
a.billingcountry = 'USA';
a.billingState = 'co';
a.billingstreet = 'unknown';
a.billingpostalcode = '80204';
a.phone = '3039291726';
insert a;


//Create an opportunity
Opportunity o = new Opportunity();
o.Name = 'test';
o.AccountId = a.id;
o.Type = 'Infor (OEM)';
o.CloseDate = date.today();
o.StageName = 'Qualified';
o.LeadSource = 'other';
insert o;

Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];

Product2 p = new Product2();
p.Cost__c = 10;
p.Name = 'testp';
p.ProductCode = '12345';
p.Family = 'Software Support';
p.Create_Service_Contract_when_Sold__c = true;
insert p;

PricebookEntry pbe = new PricebookEntry();
pbe.Product2Id = p.id;
pbe.UnitPrice = 100;
pbe.Pricebook2Id = standardPB.Id;
pbe.IsActive = true;
insert pbe;

test.startTest();
//add line item
OpportunityLineItem oli = new OpportunityLineItem();
oli.OpportunityId = o.id;
oli.PricebookEntryId = pbe.Id;
oli.UnitPrice = pbe.UnitPrice;
oli.Quantity = 10;
insert oli;

//update status
o.StageName = 'Closed Won';
update o;
test.stopTest();

}
}